diff --git a/docs/conversation.md b/docs/conversation.md index 8aaadb22b4d..ea34baa1572 100644 --- a/docs/conversation.md +++ b/docs/conversation.md @@ -97,9 +97,10 @@ | `objectId` | string | v1 | | See [Object types](constants.md#object-types) documentation for explanation | | `breakoutRoomMode` | string | v4 | | Breakout room configuration mode (see [constants list](constants.md#breakout-room-modes)) (only available with `breakout-rooms-v1` capability) | | `breakoutRoomStatus` | string | v4 | | Breakout room status (see [constants list](constants.md#breakout-room-status)) (only available with `breakout-rooms-v1` capability) | -| `status` | string | v4 | | Optional: Only available for one-to-one conversations and when `includeStatus=true` is set | -| `statusIcon` | string | v4 | | Optional: Only available for one-to-one conversations and when `includeStatus=true` is set | -| `statusMessage` | string | v4 | | Optional: Only available for one-to-one conversations and when `includeStatus=true` is set | +| `status` | string | v4 | | Optional: Only available for one-to-one conversations, when `includeStatus=true` is set and the user has a status | +| `statusIcon` | ?string | v4 | | Optional: Only available for one-to-one conversations, when `includeStatus=true` is set and the user has a status, can still be null even with a status | +| `statusMessage` | ?string | v4 | | Optional: Only available for one-to-one conversations, when `includeStatus=true` is set and the user has a status, can still be null even with a status | +| `statusClearAt` | ?int | v4 | | Optional: Only available for one-to-one conversations, when `includeStatus=true` is set and the user has a status, can still be null even with a status | | `participants` | array | v1 | v2 | **Removed** | | `guestList` | string | v1 | v2 | **Removed** | | `avatarVersion` | string | v4 | | Version of conversation avatar used to easier expiration of the avatar in case a moderator updates it, since the avatar endpoint should be cached for 24 hours. | diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 0656d038cc3..02e77539e38 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -868,10 +868,11 @@ protected function formatParticipantList(array $participants, bool $includeStatu } if (isset($statuses[$userId])) { + $clearAt = $statuses[$userId]->getClearAt(); $result['status'] = $statuses[$userId]->getStatus(); $result['statusIcon'] = $statuses[$userId]->getIcon(); $result['statusMessage'] = $statuses[$userId]->getMessage(); - $result['statusClearAt'] = $statuses[$userId]->getClearAt(); + $result['statusClearAt'] = $clearAt ? $clearAt->getTimestamp() : null; } elseif (isset($headers['X-Nextcloud-Has-User-Statuses'])) { $result['status'] = IUserStatus::OFFLINE; $result['statusIcon'] = null; diff --git a/lib/Service/RoomFormatter.php b/lib/Service/RoomFormatter.php index 104473a5dca..cf8a1726702 100644 --- a/lib/Service/RoomFormatter.php +++ b/lib/Service/RoomFormatter.php @@ -324,10 +324,11 @@ public function formatRoomV4( } if (isset($statuses[$participant])) { + $clearAt = $statuses[$participant]->getClearAt(); $roomData['status'] = $statuses[$participant]->getStatus(); $roomData['statusIcon'] = $statuses[$participant]->getIcon(); $roomData['statusMessage'] = $statuses[$participant]->getMessage(); - $roomData['statusClearAt'] = $statuses[$participant]->getClearAt(); + $roomData['statusClearAt'] = $clearAt ? $clearAt->getTimestamp() : null; } elseif (!empty($statuses)) { $roomData['status'] = IUserStatus::OFFLINE; $roomData['statusIcon'] = null; diff --git a/src/store/conversationsStore.js b/src/store/conversationsStore.js index 10048cf3d44..2dfba603cbd 100644 --- a/src/store/conversationsStore.js +++ b/src/store/conversationsStore.js @@ -23,6 +23,7 @@ import Vue from 'vue' import { getCurrentUser } from '@nextcloud/auth' import { showInfo, showSuccess, TOAST_PERMANENT_TIMEOUT } from '@nextcloud/dialogs' +import { emit } from '@nextcloud/event-bus' import { CALL, @@ -207,6 +208,16 @@ const actions = { addConversation(context, conversation) { context.commit('addConversation', conversation) + if (conversation.type === CONVERSATION.TYPE.ONE_TO_ONE && conversation.status) { + emit('user_status:status.updated', { + status: conversation.status, + message: conversation.statusMessage, + icon: conversation.statusIcon, + clearAt: conversation.statusClearAt, + userId: conversation.name, + }) + } + let currentUser = { uid: context.getters.getUserId(), displayName: context.getters.getDisplayName(),