Skip to content

Commit

Permalink
feat(archive): Finalize archived conversation behaviour
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Nov 20, 2024
1 parent 7d24127 commit d046ef0
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/conversation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
];
Expand All @@ -126,7 +126,7 @@ class Capabilities implements IPublicCapability {
'avatar',
'remind-me-later',
'note-to-self',
'archived-conversations',
'archived-conversations-v2',
'chat-summary-api',
];

Expand Down
10 changes: 3 additions & 7 deletions lib/Chat/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down Expand Up @@ -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 [];
}

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions lib/Controller/RoomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,8 @@ public function setPassword(string $password): DataResponse {
/**
* Archive a conversation
*
* Required capability: `archived-conversations-v2`
*
* @return DataResponse<Http::STATUS_OK, TalkRoom, array{}>
*
* 200: Conversation was archived
Expand All @@ -1572,6 +1574,8 @@ public function archiveConversation(): DataResponse {
/**
* Unarchive a conversation
*
* Required capability: `archived-conversations-v2`
*
* @return DataResponse<Http::STATUS_OK, TalkRoom, array{}>
*
* 200: Conversation was unarchived
Expand Down
2 changes: 2 additions & 0 deletions openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -16362,6 +16362,7 @@
"post": {
"operationId": "room-archive-conversation",
"summary": "Archive a conversation",
"description": "Required capability: `archived-conversations-v2`",
"tags": [
"room"
],
Expand Down Expand Up @@ -16442,6 +16443,7 @@
"delete": {
"operationId": "room-unarchive-conversation",
"summary": "Unarchive a conversation",
"description": "Required capability: `archived-conversations-v2`",
"tags": [
"room"
],
Expand Down
2 changes: 2 additions & 0 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -16496,6 +16496,7 @@
"post": {
"operationId": "room-archive-conversation",
"summary": "Archive a conversation",
"description": "Required capability: `archived-conversations-v2`",
"tags": [
"room"
],
Expand Down Expand Up @@ -16576,6 +16577,7 @@
"delete": {
"operationId": "room-unarchive-conversation",
"summary": "Unarchive a conversation",
"description": "Required capability: `archived-conversations-v2`",
"tags": [
"room"
],
Expand Down
10 changes: 8 additions & 2 deletions src/types/openapi/openapi-full.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 8 additions & 2 deletions src/types/openapi/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d046ef0

Please sign in to comment.