diff --git a/lib/Model/Message.php b/lib/Model/Message.php index 60245778c07..4ed526e1b1d 100644 --- a/lib/Model/Message.php +++ b/lib/Model/Message.php @@ -172,6 +172,13 @@ public function isReplyable(): bool { public function toArray(): array { $expireDate = $this->getComment()->getExpireDate(); + $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(), @@ -185,7 +192,7 @@ public function toArray(): array { 'messageType' => $this->getMessageType(), 'isReplyable' => $this->isReplyable(), 'referenceId' => (string) $this->getComment()->getReferenceId(), - 'reactions' => $this->getComment()->getReactions(), + 'reactions' => $reactions, 'expirationTimestamp' => $expireDate ? $expireDate->getTimestamp() : 0, ];