From d6683b4fc9377768921d25934aa9a340d710f0e3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 25 Mar 2024 10:04:34 +0100 Subject: [PATCH 1/3] fix(flow): Don't use the current participant when posting the flow message Otherwise the own user would not trigger a notification Signed-off-by: Joas Schilling --- lib/Flow/Operation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Flow/Operation.php b/lib/Flow/Operation.php index 24d529e922d..1d94ed4adcb 100644 --- a/lib/Flow/Operation.php +++ b/lib/Flow/Operation.php @@ -126,8 +126,8 @@ 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(), From f12f0540dcdb050d12d4c9c02a610ce5d5fb492f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 25 Mar 2024 10:05:11 +0100 Subject: [PATCH 2/3] fix(notification): Fix notifications in note-to-self Signed-off-by: Joas Schilling --- lib/Notification/Notifier.php | 1 + 1 file changed, 1 insertion(+) 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'; From 43164e389b1a6d863a62b63ea952aedfc284e34d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 25 Mar 2024 10:05:44 +0100 Subject: [PATCH 3/3] fix(chat): Allow flow-bots to update the last message info Signed-off-by: Joas Schilling --- lib/Chat/ChatManager.php | 17 +++++++++++++++-- lib/Flow/Operation.php | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) 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 1d94ed4adcb..0ef63fd3443 100644 --- a/lib/Flow/Operation.php +++ b/lib/Flow/Operation.php @@ -132,6 +132,7 @@ public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatch $this->prepareMention($mode, $participant) . $message, new \DateTime(), rateLimitGuestMentions: false, + forceLastMessageUpdate: true, ); } catch (UnexpectedValueException|ParticipantNotFoundException|RoomNotFoundException) { continue;