diff --git a/docs/chat.md b/docs/chat.md index 93e4b268dd0..dac1cdcb0b5 100644 --- a/docs/chat.md +++ b/docs/chat.md @@ -41,23 +41,24 @@ Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1`: since Nextcloud 13 - Data: Array of messages, each message has at least: -| field | type | Description | -|---------------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `id` | int | ID of the comment | -| `token` | string | Conversation token | -| `actorType` | string | See [Constants - Actor types of chat messages](constants.md#actor-types-of-chat-messages) | -| `actorId` | string | Actor id of the message author | -| `actorDisplayName` | string | Display name of the message author | -| `timestamp` | int | Timestamp in seconds and UTC time zone | -| `systemMessage` | string | empty for normal chat message or the type of the system message (untranslated) | -| `messageType` | string | Currently known types are `comment`, `comment_deleted`, `system` and `command` | -| `isReplyable` | bool | True if the user can post a reply to this message (only available with `chat-replies` capability) | -| `referenceId` | string | A reference string that was given while posting the message to be able to identify a sent message again (only available with `chat-reference-id` capability) | -| `message` | string | Message string with placeholders (see [Rich Object String](https://github.com/nextcloud/server/issues/1706)) | -| `messageParameters` | array | Message parameters for `message` (see [Rich Object String](https://github.com/nextcloud/server/issues/1706)) | -| `parent` | array | **Optional:** See `Parent data` below | -| `reactions` | int[] | **Optional:** An array map with relation between reaction emoji and total count of reactions with this emoji | -| `reactionsSelf` | string[] | **Optional:** When the user reacted this is the list of emojis the user reacted with | +| field | type | Description | +|------------------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `id` | int | ID of the comment | +| `token` | string | Conversation token | +| `actorType` | string | See [Constants - Actor types of chat messages](constants.md#actor-types-of-chat-messages) | +| `actorId` | string | Actor id of the message author | +| `actorDisplayName` | string | Display name of the message author | +| `timestamp` | int | Timestamp in seconds and UTC time zone | +| `systemMessage` | string | empty for normal chat message or the type of the system message (untranslated) | +| `messageType` | string | Currently known types are `comment`, `comment_deleted`, `system` and `command` | +| `isReplyable` | bool | True if the user can post a reply to this message (only available with `chat-replies` capability) | +| `referenceId` | string | A reference string that was given while posting the message to be able to identify a sent message again (only available with `chat-reference-id` capability) | +| `message` | string | Message string with placeholders (see [Rich Object String](https://github.com/nextcloud/server/issues/1706)) | +| `messageParameters` | array | Message parameters for `message` (see [Rich Object String](https://github.com/nextcloud/server/issues/1706)) | +| `expirationTimestamp` | int | Unix time stamp when the message expires and show be removed from the clients UI without further note or warning (only available with `message-expiration` capability) | +| `parent` | array | **Optional:** See `Parent data` below | +| `reactions` | int[] | **Optional:** An array map with relation between reaction emoji and total count of reactions with this emoji | +| `reactionsSelf` | string[] | **Optional:** When the user reacted this is the list of emojis the user reacted with | #### Parent data diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php index 51666142d04..22540811bdb 100644 --- a/lib/Chat/Parser/SystemMessage.php +++ b/lib/Chat/Parser/SystemMessage.php @@ -461,7 +461,6 @@ public function parseMessage(Message $chatMessage): void { $hours = $parameters['seconds'] >= 3600 ? (int) round($parameters['seconds'] / 3600) : 0; $minutes = (int) round($parameters['seconds'] / 60); - $parsedParameters['seconds'] = $parameters['seconds']; if ($currentUserIsActor) { if ($weeks > 0) { $parsedMessage = $this->l->n('You set the message expiration to %n week', 'You set the message expiration to %n weeks', $weeks); diff --git a/lib/Model/Message.php b/lib/Model/Message.php index fd14eaaba8d..60245778c07 100644 --- a/lib/Model/Message.php +++ b/lib/Model/Message.php @@ -170,6 +170,8 @@ public function isReplyable(): bool { } public function toArray(): array { + $expireDate = $this->getComment()->getExpireDate(); + $data = [ 'id' => (int) $this->getComment()->getId(), 'token' => $this->getRoom()->getToken(), @@ -184,6 +186,7 @@ public function toArray(): array { 'isReplyable' => $this->isReplyable(), 'referenceId' => (string) $this->getComment()->getReferenceId(), 'reactions' => $this->getComment()->getReactions(), + 'expirationTimestamp' => $expireDate ? $expireDate->getTimestamp() : 0, ]; if ($this->getMessageType() === ChatManager::VERB_MESSAGE_DELETED) {