mirror of
https://github.com/nextcloud/spreed.git
synced 2025-08-16 15:27:59 +00:00
fix(threads): Add thread attendee and sync info when replying
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
@ -400,9 +400,28 @@ class ChatManager {
|
||||
$shouldFlush = $this->notificationManager->defer();
|
||||
try {
|
||||
$this->commentsManager->save($comment);
|
||||
$messageId = (int)$comment->getId();
|
||||
$threadId = (int)$comment->getTopmostParentId();
|
||||
$thread = null;
|
||||
|
||||
if ($threadId) {
|
||||
try {
|
||||
$thread = $this->threadService->findByThreadId($threadId);
|
||||
} catch (DoesNotExistException) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($participant instanceof Participant) {
|
||||
$this->participantService->updateLastReadMessage($participant, (int)$comment->getId());
|
||||
$this->participantService->updateLastReadMessage($participant, $messageId);
|
||||
|
||||
if ($thread !== null) {
|
||||
$this->threadService->addAttendeeToThread(
|
||||
$participant->getAttendee(),
|
||||
$thread,
|
||||
);
|
||||
|
||||
$this->threadService->updateLastMessageInfoAfterReply($thread, $messageId);
|
||||
}
|
||||
}
|
||||
|
||||
// Update last_message
|
||||
|
@ -262,6 +262,7 @@ class ChatController extends AEnvironmentAwareOCSController {
|
||||
} catch (IRateLimitExceededException) {
|
||||
return new DataResponse(['error' => 'mentions'], Http::STATUS_TOO_MANY_REQUESTS);
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->warning($e->getMessage());
|
||||
return new DataResponse(['error' => 'message'], Http::STATUS_BAD_REQUEST);
|
||||
}
|
||||
|
||||
|
@ -108,6 +108,18 @@ class ThreadService {
|
||||
}
|
||||
}
|
||||
|
||||
public function updateLastMessageInfoAfterReply(Thread $thread, int $lastMessageId): void {
|
||||
$query = $this->connection->getQueryBuilder();
|
||||
$query->update('talk_threads')
|
||||
->set('num_replies', $query->func()->add('num_replies', $query->expr()->literal(1)))
|
||||
->set('last_message_id', $query->createNamedParameter($lastMessageId))
|
||||
->where($query->expr()->eq('id', $query->createNamedParameter($thread->getId())));
|
||||
$query->executeStatement();
|
||||
|
||||
$thread->setNumReplies($thread->getNumReplies() + 1);
|
||||
$thread->setLastMessageId($lastMessageId);
|
||||
}
|
||||
|
||||
public function deleteByRoom(Room $room): void {
|
||||
$this->threadMapper->deleteByRoomId($room->getId());
|
||||
$this->threadAttendeeMapper->deleteByRoomId($room->getId());
|
||||
|
Reference in New Issue
Block a user