diff --git a/lib/Model/Message.php b/lib/Model/Message.php index fd14eaaba8d..ddff7ec680b 100644 --- a/lib/Model/Message.php +++ b/lib/Model/Message.php @@ -170,6 +170,13 @@ public function isReplyable(): bool { } public function toArray(): array { + $reactions = $this->getComment()->getReactions(); + if (empty($reactions)) { + // Cheating here to make sure the reactions array is always a + // JSON object on the API, even when there is no reaction at all. + $reactions = new \StdClass(); + } + $data = [ 'id' => (int) $this->getComment()->getId(), 'token' => $this->getRoom()->getToken(), @@ -183,7 +190,7 @@ public function toArray(): array { 'messageType' => $this->getMessageType(), 'isReplyable' => $this->isReplyable(), 'referenceId' => (string) $this->getComment()->getReferenceId(), - 'reactions' => $this->getComment()->getReactions(), + 'reactions' => $reactions, ]; if ($this->getMessageType() === ChatManager::VERB_MESSAGE_DELETED) {