From d046ef01ef89ba5e40d33465cc4cb104faee45cf Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 19 Nov 2024 18:47:34 +0100 Subject: [PATCH] feat(archive): Finalize archived conversation behaviour Signed-off-by: Joas Schilling --- docs/capabilities.md | 2 +- docs/conversation.md | 2 +- lib/Capabilities.php | 4 ++-- lib/Chat/Notifier.php | 10 +++------- lib/Controller/RoomController.php | 4 ++++ openapi-full.json | 2 ++ openapi.json | 2 ++ src/types/openapi/openapi-full.ts | 10 ++++++++-- src/types/openapi/openapi.ts | 10 ++++++++-- 9 files changed, 31 insertions(+), 15 deletions(-) diff --git a/docs/capabilities.md b/docs/capabilities.md index b34aef1018d..dc7ad23cdc0 100644 --- a/docs/capabilities.md +++ b/docs/capabilities.md @@ -157,7 +157,7 @@ * `edit-messages-note-to-self` - Messages in note-to-self conversations can be edited indefinitely ## 20.1 -* `archived-conversations` (local) - Conversations can be marked as archived which will hide them from the conversation list by default +* `archived-conversations-v2` (local) - Conversations can be marked as archived which will hide them from the conversation list by default * `talk-polls-drafts` - Whether moderators can store and retrieve poll drafts * `download-call-participants` - Whether the endpoints for moderators to download the call participants is available * `chat-summary-api` (local) - Whether the endpoint to get summarized chat messages in a conversation is available diff --git a/docs/conversation.md b/docs/conversation.md index efd24a8fde5..13fe92972b0 100644 --- a/docs/conversation.md +++ b/docs/conversation.md @@ -110,7 +110,7 @@ | `callRecording` | int | v4 | | Type of call recording (see [Constants - Call recording status](constants.md#call-recording-status)) (only available with `recording-v1` capability) | | `recordingConsent` | int | v4 | | Whether recording consent is required before joining a call (Only 0 and 1 will be returned, see [constants list](constants.md#recording-consent-required)) (only available with `recording-consent` capability) | | `mentionPermissions` | int | v4 | | Whether all participants can mention using `@all` or only moderators (see [constants list](constants.md#mention-permissions)) (only available with `mention-permissions` capability) | -| `isArchived` | bool | v4 | | Flag if the conversation is archived by the user (only available with `archived-conversations` capability) | | +| `isArchived` | bool | v4 | | Flag if the conversation is archived by the user (only available with `archived-conversations-v2` capability) | | ## Creating a new conversation diff --git a/lib/Capabilities.php b/lib/Capabilities.php index 811cbd0c737..1d9e42fcfd7 100644 --- a/lib/Capabilities.php +++ b/lib/Capabilities.php @@ -105,7 +105,7 @@ class Capabilities implements IPublicCapability { 'chat-reference-id', 'mention-permissions', 'edit-messages-note-to-self', - 'archived-conversations', + 'archived-conversations-v2', 'talk-polls-drafts', 'download-call-participants', ]; @@ -126,7 +126,7 @@ class Capabilities implements IPublicCapability { 'avatar', 'remind-me-later', 'note-to-self', - 'archived-conversations', + 'archived-conversations-v2', 'chat-summary-api', ]; diff --git a/lib/Chat/Notifier.php b/lib/Chat/Notifier.php index 7829f702f23..2f8d462678b 100644 --- a/lib/Chat/Notifier.php +++ b/lib/Chat/Notifier.php @@ -77,7 +77,7 @@ public function notifyMentionedUsers(Room $chat, IComment $comment, array $alrea } foreach ($usersToNotify as $mentionedUser) { - if ($this->shouldMentionedUserBeNotified($mentionedUser['id'], $comment, $chat, $mentionedUser['attendee'] ?? null, $mentionedUser['reason'])) { + if ($this->shouldMentionedUserBeNotified($mentionedUser['id'], $comment, $chat, $mentionedUser['attendee'] ?? null)) { if (!$silent) { $notification->setUser($mentionedUser['id']); if (isset($mentionedUser['reason'])) { @@ -209,7 +209,7 @@ public function notifyReplyToAuthor(Room $chat, IComment $comment, IComment $rep ]; } - if (!$this->shouldMentionedUserBeNotified($replyTo->getActorId(), $comment, $chat, null, 'reply')) { + if (!$this->shouldMentionedUserBeNotified($replyTo->getActorId(), $comment, $chat)) { return []; } @@ -565,7 +565,7 @@ protected function getDefaultGroupNotification(): int { * 3. The user must be a participant of the room * 4. The user must not be active in the room */ - protected function shouldMentionedUserBeNotified(string $userId, IComment $comment, Room $room, ?Attendee $attendee, string $reason): bool { + protected function shouldMentionedUserBeNotified(string $userId, IComment $comment, Room $room, ?Attendee $attendee = null): bool { if ($comment->getActorType() === Attendee::ACTOR_USERS && $userId === $comment->getActorId()) { // Do not notify the user if they mentioned themselves return false; @@ -583,10 +583,6 @@ protected function shouldMentionedUserBeNotified(string $userId, IComment $comme $participant = new Participant($room, $attendee, null); } - if ($reason === 'all' && $attendee->isArchived()) { - return false; - } - if ($room->getLobbyState() !== Webinary::LOBBY_NONE && !($participant->getPermissions() & Attendee::PERMISSIONS_LOBBY_IGNORE)) { return false; diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 4efb1c853ff..0bb34dfb904 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -1557,6 +1557,8 @@ public function setPassword(string $password): DataResponse { /** * Archive a conversation * + * Required capability: `archived-conversations-v2` + * * @return DataResponse * * 200: Conversation was archived @@ -1572,6 +1574,8 @@ public function archiveConversation(): DataResponse { /** * Unarchive a conversation * + * Required capability: `archived-conversations-v2` + * * @return DataResponse * * 200: Conversation was unarchived diff --git a/openapi-full.json b/openapi-full.json index 8362835488b..967f703e5f5 100644 --- a/openapi-full.json +++ b/openapi-full.json @@ -16362,6 +16362,7 @@ "post": { "operationId": "room-archive-conversation", "summary": "Archive a conversation", + "description": "Required capability: `archived-conversations-v2`", "tags": [ "room" ], @@ -16442,6 +16443,7 @@ "delete": { "operationId": "room-unarchive-conversation", "summary": "Unarchive a conversation", + "description": "Required capability: `archived-conversations-v2`", "tags": [ "room" ], diff --git a/openapi.json b/openapi.json index 758b812176a..be7a17ecf34 100644 --- a/openapi.json +++ b/openapi.json @@ -16496,6 +16496,7 @@ "post": { "operationId": "room-archive-conversation", "summary": "Archive a conversation", + "description": "Required capability: `archived-conversations-v2`", "tags": [ "room" ], @@ -16576,6 +16577,7 @@ "delete": { "operationId": "room-unarchive-conversation", "summary": "Unarchive a conversation", + "description": "Required capability: `archived-conversations-v2`", "tags": [ "room" ], diff --git a/src/types/openapi/openapi-full.ts b/src/types/openapi/openapi-full.ts index aea9b4ed461..21ea412361b 100644 --- a/src/types/openapi/openapi-full.ts +++ b/src/types/openapi/openapi-full.ts @@ -1291,9 +1291,15 @@ export type paths = { }; get?: never; put?: never; - /** Archive a conversation */ + /** + * Archive a conversation + * @description Required capability: `archived-conversations-v2` + */ post: operations["room-archive-conversation"]; - /** Unarchive a conversation */ + /** + * Unarchive a conversation + * @description Required capability: `archived-conversations-v2` + */ delete: operations["room-unarchive-conversation"]; options?: never; head?: never; diff --git a/src/types/openapi/openapi.ts b/src/types/openapi/openapi.ts index 58cf51d6e22..ea20a29be16 100644 --- a/src/types/openapi/openapi.ts +++ b/src/types/openapi/openapi.ts @@ -1293,9 +1293,15 @@ export type paths = { }; get?: never; put?: never; - /** Archive a conversation */ + /** + * Archive a conversation + * @description Required capability: `archived-conversations-v2` + */ post: operations["room-archive-conversation"]; - /** Unarchive a conversation */ + /** + * Unarchive a conversation + * @description Required capability: `archived-conversations-v2` + */ delete: operations["room-unarchive-conversation"]; options?: never; head?: never;