Skip to content

Commit

Permalink
Merge pull request #11919 from nextcloud/backport/11918/stable28
Browse files Browse the repository at this point in the history
[stable28] fix(flow): Fix flow notifications in note-to-self and on own actions
  • Loading branch information
nickvergessen authored Mar 25, 2024
2 parents 4251bba + 0cbb5aa commit 5611ef6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
16 changes: 14 additions & 2 deletions lib/Chat/ChatManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,18 @@ public function addChangelogMessage(Room $chat, string $message): IComment {
* @param string $referenceId
* @return IComment
*/
public function sendMessage(Room $chat, ?Participant $participant, string $actorType, string $actorId, string $message, \DateTime $creationDateTime, ?IComment $replyTo, string $referenceId, bool $silent): IComment {
public function sendMessage(
Room $chat,
?Participant $participant,
string $actorType,
string $actorId,
string $message,
\DateTime $creationDateTime,
?IComment $replyTo,
string $referenceId,
bool $silent,
bool $forceLastMessageUpdate = false, // Remove when dropping commands
): IComment {
$comment = $this->commentsManager->create($actorType, $actorId, 'chat', (string) $chat->getId());
$comment->setMessage($message, self::MAX_CHAT_LENGTH);
$comment->setCreationDateTime($creationDateTime);
Expand Down Expand Up @@ -322,9 +333,10 @@ public function sendMessage(Room $chat, ?Participant $participant, string $actor
$this->participantService->updateLastReadMessage($participant, (int) $comment->getId());
}

// Update last_message
// Update last_message (not for commands)
if ($comment->getActorType() !== Attendee::ACTOR_BOTS
|| $comment->getActorId() === Attendee::ACTOR_ID_CHANGELOG
|| $forceLastMessageUpdate
|| str_starts_with($comment->getActorId(), Attendee::ACTOR_BOT_PREFIX)) {
$this->roomService->setLastMessage($chat, $comment);
$this->unreadCountCache->clear($chat->getId() . '-');
Expand Down
7 changes: 4 additions & 3 deletions lib/Flow/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,15 @@ public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatch

$this->chatManager->sendMessage(
$room,
$participant,
'bots',
null,
Attendee::ACTOR_BOTS,
$participant->getAttendee()->getActorId(),
$this->prepareMention($mode, $participant) . $message,
new \DateTime(),
null,
'',
false
false,
forceLastMessageUpdate: true,
);
} catch (UnexpectedValueException $e) {
continue;
Expand Down
1 change: 1 addition & 0 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,7 @@ protected function getRoomType(Room $room): string {
case Room::TYPE_ONE_TO_ONE_FORMER:
return 'one2one';
case Room::TYPE_GROUP:
case Room::TYPE_NOTE_TO_SELF:
return 'group';
case Room::TYPE_PUBLIC:
return 'public';
Expand Down

0 comments on commit 5611ef6

Please sign in to comment.