Skip to content

Commit

Permalink
fixup! fixup! Allow to reply to messages and return the parent on the…
Browse files Browse the repository at this point in the history
… message endpoints
  • Loading branch information
nickvergessen committed Jul 25, 2019
1 parent e829197 commit 8d3420d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/Chat/ChatManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ public function sendMessage(Room $chat, Participant $participant, string $actorT

/**
* @param Room $chat
* @param int $parentId
* @param string $parentId
* @return IComment
* @throws NotFoundException
*/
public function getParentComment(Room $chat, int $parentId): IComment {
$comment = $this->commentsManager->get((string) $parentId);
public function getParentComment(Room $chat, string $parentId): IComment {
$comment = $this->commentsManager->get($parentId);

if ($comment->getObjectType() !== 'chat' || $comment->getObjectId() !== (string) $chat->getId()) {
throw new NotFoundException('Parent not found in the right context');
Expand Down
7 changes: 3 additions & 4 deletions lib/Controller/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function sendMessage(string $message, string $actorDisplayName = '', int
$parent = null;
if ($replyTo !== 0) {
try {
$parent = $this->chatManager->getParentComment($this->room, $replyTo);
$parent = $this->chatManager->getParentComment($this->room, (string) $replyTo);
} catch (NotFoundException $e) {
// Someone is trying to reply cross-rooms or to a non-existing message
return new DataResponse([], Http::STATUS_BAD_REQUEST);
Expand Down Expand Up @@ -256,9 +256,8 @@ public function receiveMessages(int $lookIntoFuture, int $limit = 100, int $last
continue;
}

$parentId = (int) $comment->getParentId();
if ($parentId !== 0) {
$parentIds[$id] = $parentId;
if ($comment->getParentId() !== '0') {
$parentIds[$id] = $comment->getParentId();
}

$messages[] = $this->messageToData($message);
Expand Down

0 comments on commit 8d3420d

Please sign in to comment.