Skip to content
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
16 changes: 14 additions & 2 deletions lib/Chat/ChatManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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() . '-');
Expand Down
7 changes: 4 additions & 3 deletions lib/Flow/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down