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
9 changes: 6 additions & 3 deletions lib/BackgroundJob/SendScheduledMessages.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ protected function run($argument): void {
$metaData = $message->getDecodedMetaData();
$threadId = $message->getThreadId();
$threadTitle = $metaData[ScheduledMessage::METADATA_THREAD_TITLE] ?? null;
$comment = $this->chatManager->sendMessage($room,
$comment = $this->chatManager->sendMessage(
$room,
$participant,
$message->getActorType(),
$message->getActorId(),
Expand All @@ -167,7 +168,9 @@ protected function run($argument): void {
$parent,
'',
$metaData[ScheduledMessage::METADATA_SILENT] ?? false,
threadId: $threadId
threadId: $threadId,
threadTitle: $threadTitle,
fromScheduledMessage: true,
);
$this->logger->debug('Sent scheduled message ' . $message->getId() . ' to room ' . $message->getRoomId() . ' for ' . $message->getActorType() . ' ' . $message->getActorId());
if ($threadId === Thread::THREAD_CREATE && $threadTitle !== '') {
Expand All @@ -185,7 +188,7 @@ protected function run($argument): void {
null,
$comment,
true,
true
true,
);
$this->logger->debug('Created thread ' . $thread->getId() . ' in room ' . $message->getRoomId() . ' for scheduled message ' . $message->getId() . ' for ' . $message->getActorType() . ' ' . $message->getActorId());
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Chat/ChatManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ public function sendMessage(
bool $rateLimitGuestMentions = true,
int $threadId = 0,
string $threadTitle = '',
bool $fromScheduledMessage = false,
): IComment {
if ($chat->isFederatedConversation()) {
$e = new MessagingNotAllowedException();
Expand Down Expand Up @@ -466,7 +467,7 @@ public function sendMessage(
}
}

if ($participant instanceof Participant) {
if (!$fromScheduledMessage && $participant instanceof Participant) {
$this->participantService->updateLastReadMessage($participant, $messageId);
}

Expand Down
13 changes: 7 additions & 6 deletions tests/integration/features/chat-4/scheduled-messages.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ Feature: chat-4/scheduling
| roomName | room |
And user "participant1" adds user "participant2" to room "room" with 200 (v4)
And user "participant2" sends message "Message" to room "room" with 201
Then user "participant1" reads message "Message" in room "room" with 200
Then user "participant1" is participant of the following rooms (v4)
| id | type | hasScheduledMessages |
| room | 2 |0 |
| id | type | hasScheduledMessages | unreadMessages | lastReadMessage |
| room | 2 | 0 | 0 | Message |

Scenario: Schedule a message
When user "participant1" schedules a message to room "room" with 201
Expand All @@ -19,14 +20,14 @@ Feature: chat-4/scheduling
| id | actorType | actorId | threadId | parent | message | messageType | sendAt | silent |
| Message 1 | users | participant1 | 0 | null | Message 1 | comment | {NOW} | false |
And user "participant1" is participant of the following rooms (v4)
| id | type | hasScheduledMessages |
| room | 2 | 1 |
| id | type | hasScheduledMessages | unreadMessages | lastReadMessage |
| room | 2 | 1 | 0 | Message |
When wait for 4 seconds
And force run "OCA\Talk\BackgroundJob\SendScheduledMessages" background jobs
Then user "participant1" sees the following scheduled messages in room "room" with 200
And user "participant1" is participant of the following rooms (v4)
| id | type | hasScheduledMessages |
| room | 2 | 0 |
| id | type | hasScheduledMessages | unreadMessages | lastReadMessage |
| room | 2 | 0 | 1 | Message |
Then user "participant2" sees the following messages in room "room" with 200
| room | actorType | actorId | actorDisplayName | messageType | message | messageParameters |
| room | users | participant1 | participant1-displayname | comment | Message 1 | [] |
Expand Down
Loading