diff options
Diffstat (limited to 'lib/Chat/ChatManager.php')
-rw-r--r-- | lib/Chat/ChatManager.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Chat/ChatManager.php b/lib/Chat/ChatManager.php index b21d90b4a..b63fa0f79 100644 --- a/lib/Chat/ChatManager.php +++ b/lib/Chat/ChatManager.php @@ -247,6 +247,22 @@ class ChatManager { return $comment; } + /** + * @param Room $chat + * @param string $messageId + * @return IComment + * @throws NotFoundException + */ + public function getComment(Room $chat, string $messageId): IComment { + $comment = $this->commentsManager->get($messageId); + + if ($comment->getObjectType() !== 'chat' || $comment->getObjectId() !== (string) $chat->getId()) { + throw new NotFoundException('Message not found in the right context'); + } + + return $comment; + } + public function getLastReadMessageFromLegacy(Room $chat, IUser $user): int { $marker = $this->commentsManager->getReadMark('chat', $chat->getId(), $user); if ($marker === null) { |