diff --git a/lib/Chat/ChatManager.php b/lib/Chat/ChatManager.php index eef6972066d..ba2feca9486 100644 --- a/lib/Chat/ChatManager.php +++ b/lib/Chat/ChatManager.php @@ -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); @@ -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() . '-'); diff --git a/lib/Flow/Operation.php b/lib/Flow/Operation.php index aa185d6fab2..780814fb194 100644 --- a/lib/Flow/Operation.php +++ b/lib/Flow/Operation.php @@ -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; diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index 92aa8cad32d..c6893de498e 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -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';