mirror of
https://github.com/nextcloud/spreed.git
synced 2025-12-18 05:20:50 +01:00
Expose message expiration for chat message objects
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
5871010f43
commit
14e002a6d2
2 changed files with 21 additions and 17 deletions
35
docs/chat.md
35
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
|
||||
|
||||
|
|
|
|||
|
|
@ -170,6 +170,8 @@ class Message {
|
|||
}
|
||||
|
||||
public function toArray(): array {
|
||||
$expireDate = $this->getComment()->getExpireDate();
|
||||
|
||||
$data = [
|
||||
'id' => (int) $this->getComment()->getId(),
|
||||
'token' => $this->getRoom()->getToken(),
|
||||
|
|
@ -184,6 +186,7 @@ class Message {
|
|||
'isReplyable' => $this->isReplyable(),
|
||||
'referenceId' => (string) $this->getComment()->getReferenceId(),
|
||||
'reactions' => $this->getComment()->getReactions(),
|
||||
'expirationTimestamp' => $expireDate ? $expireDate->getTimestamp() : 0,
|
||||
];
|
||||
|
||||
if ($this->getMessageType() === ChatManager::VERB_MESSAGE_DELETED) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue