Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(flow): Fix flow notifications in note-to-self and on own actions #11918

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/Chat/ChatManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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() . '-');
Expand Down
5 changes: 3 additions & 2 deletions lib/Flow/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Loading