Skip to content

Commit 5611ef6

Browse files
Merge pull request #11919 from nextcloud/backport/11918/stable28
[stable28] fix(flow): Fix flow notifications in note-to-self and on own actions
2 parents 4251bba + 0cbb5aa commit 5611ef6

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

lib/Chat/ChatManager.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,18 @@ public function addChangelogMessage(Room $chat, string $message): IComment {
287287
* @param string $referenceId
288288
* @return IComment
289289
*/
290-
public function sendMessage(Room $chat, ?Participant $participant, string $actorType, string $actorId, string $message, \DateTime $creationDateTime, ?IComment $replyTo, string $referenceId, bool $silent): IComment {
290+
public function sendMessage(
291+
Room $chat,
292+
?Participant $participant,
293+
string $actorType,
294+
string $actorId,
295+
string $message,
296+
\DateTime $creationDateTime,
297+
?IComment $replyTo,
298+
string $referenceId,
299+
bool $silent,
300+
bool $forceLastMessageUpdate = false, // Remove when dropping commands
301+
): IComment {
291302
$comment = $this->commentsManager->create($actorType, $actorId, 'chat', (string) $chat->getId());
292303
$comment->setMessage($message, self::MAX_CHAT_LENGTH);
293304
$comment->setCreationDateTime($creationDateTime);
@@ -322,9 +333,10 @@ public function sendMessage(Room $chat, ?Participant $participant, string $actor
322333
$this->participantService->updateLastReadMessage($participant, (int) $comment->getId());
323334
}
324335

325-
// Update last_message
336+
// Update last_message (not for commands)
326337
if ($comment->getActorType() !== Attendee::ACTOR_BOTS
327338
|| $comment->getActorId() === Attendee::ACTOR_ID_CHANGELOG
339+
|| $forceLastMessageUpdate
328340
|| str_starts_with($comment->getActorId(), Attendee::ACTOR_BOT_PREFIX)) {
329341
$this->roomService->setLastMessage($chat, $comment);
330342
$this->unreadCountCache->clear($chat->getId() . '-');

lib/Flow/Operation.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,15 @@ public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatch
121121

122122
$this->chatManager->sendMessage(
123123
$room,
124-
$participant,
125-
'bots',
124+
null,
125+
Attendee::ACTOR_BOTS,
126126
$participant->getAttendee()->getActorId(),
127127
$this->prepareMention($mode, $participant) . $message,
128128
new \DateTime(),
129129
null,
130130
'',
131-
false
131+
false,
132+
forceLastMessageUpdate: true,
132133
);
133134
} catch (UnexpectedValueException $e) {
134135
continue;

lib/Notification/Notifier.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@ protected function getRoomType(Room $room): string {
874874
case Room::TYPE_ONE_TO_ONE_FORMER:
875875
return 'one2one';
876876
case Room::TYPE_GROUP:
877+
case Room::TYPE_NOTE_TO_SELF:
877878
return 'group';
878879
case Room::TYPE_PUBLIC:
879880
return 'public';

0 commit comments

Comments
 (0)