diff --git a/lib/Chat/ChatManager.php b/lib/Chat/ChatManager.php index 93479d68d7c..8ee9a12ddd4 100644 --- a/lib/Chat/ChatManager.php +++ b/lib/Chat/ChatManager.php @@ -285,7 +285,19 @@ public function addChangelogMessage(Room $chat, string $message): IComment { * @throws MessageTooLongException * @throws MessagingNotAllowedException */ - public function sendMessage(Room $chat, ?Participant $participant, string $actorType, string $actorId, string $message, \DateTime $creationDateTime, ?IComment $replyTo = null, string $referenceId = '', bool $silent = false, bool $rateLimitGuestMentions = true): IComment { + public function sendMessage( + Room $chat, + ?Participant $participant, + string $actorType, + string $actorId, + string $message, + \DateTime $creationDateTime, + ?IComment $replyTo = null, + string $referenceId = '', + bool $silent = false, + bool $rateLimitGuestMentions = true, + bool $forceLastMessageUpdate = false, // Remove when dropping commands + ): IComment { if ($chat->isFederatedConversation()) { $e = new MessagingNotAllowedException(); $this->logger->error('Attempt to post system message into proxy conversation', ['exception' => $e]); @@ -338,9 +350,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 24d529e922d..0ef63fd3443 100644 --- a/lib/Flow/Operation.php +++ b/lib/Flow/Operation.php @@ -126,12 +126,13 @@ 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(), rateLimitGuestMentions: false, + forceLastMessageUpdate: true, ); } catch (UnexpectedValueException|ParticipantNotFoundException|RoomNotFoundException) { continue; diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index 88e93aa6462..683212f5bd2 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -897,6 +897,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';