Skip to content
Merged
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
15 changes: 9 additions & 6 deletions lib/Controller/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ protected function parseCommentToResponse(IComment $comment, ?Message $parentMes
}

try {
$thread = $this->threadService->findByThreadId($this->room->getId(), (int)$comment->getTopmostParentId());
$threadId = (int)$comment->getTopmostParentId() ?: (int)$comment->getId();
$thread = $this->threadService->findByThreadId($this->room->getId(), $threadId);
} catch (DoesNotExistException) {
$thread = null;
}
Expand Down Expand Up @@ -682,7 +683,7 @@ protected function prepareCommentsAsDataResponse(array $comments, int $lastCommo
}

$this->sharePreloader->preloadShares($comments);
$potentialThreadIds = array_map(static fn (IComment $comment) => (int)$comment->getTopmostParentId(), $comments);
$potentialThreadIds = array_map(static fn (IComment $comment) => (int)$comment->getTopmostParentId() ?: (int)$comment->getId(), $comments);
$threads = $this->threadService->findByThreadIds($this->room->getId(), $potentialThreadIds);

$i = 0;
Expand Down Expand Up @@ -984,7 +985,8 @@ public function deleteMessage(int $messageId): DataResponse {
$this->messageParser->parseMessage($message);

try {
$thread = $this->threadService->findByThreadId($this->room->getId(), (int)$comment->getTopmostParentId());
$threadId = (int)$comment->getTopmostParentId() ?: (int)$comment->getId();
$thread = $this->threadService->findByThreadId($this->room->getId(), $threadId);
} catch (DoesNotExistException) {
$thread = null;
}
Expand Down Expand Up @@ -1107,7 +1109,8 @@ public function editMessage(int $messageId, string $message): DataResponse {
$this->messageParser->parseMessage($parseMessage);

try {
$thread = $this->threadService->findByThreadId($this->room->getId(), (int)$comment->getTopmostParentId());
$threadId = (int)$comment->getTopmostParentId() ?: (int)$comment->getId();
$thread = $this->threadService->findByThreadId($this->room->getId(), $threadId);
} catch (DoesNotExistException) {
$thread = null;
}
Expand Down Expand Up @@ -1626,7 +1629,7 @@ public function getObjectsSharedInRoom(string $objectType, int $lastKnownMessage
protected function getMessagesForRoom(array $messageIds): array {
$comments = $this->chatManager->getMessagesForRoomById($this->room, $messageIds);
$this->sharePreloader->preloadShares($comments);
$potentialThreadIds = array_map(static fn (IComment $comment) => (int)$comment->getTopmostParentId(), $comments);
$potentialThreadIds = array_map(static fn (IComment $comment) => (int)$comment->getTopmostParentId() ?: (int)$comment->getId(), $comments);
$threads = $this->threadService->findByThreadIds($this->room->getId(), $potentialThreadIds);

$messages = [];
Expand All @@ -1646,7 +1649,7 @@ protected function getMessagesForRoom(array $messageIds): array {
continue;
}

$threadId = (int)$comment->getTopmostParentId();
$threadId = (int)$comment->getTopmostParentId() ?: (int)$comment->getId();
$messages[$comment->getId()] = $message->toArray($this->getResponseFormat(), $threads[$threadId] ?? null);
}

Expand Down
Loading