From 65238d1b8f487596dc79b19fe6a6be3a4fb417be Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 2 Dec 2020 13:55:24 +0100 Subject: Adjustments for listable rooms after review Signed-off-by: Vincent Petry --- docs/chat.md | 4 ++-- docs/constants.md | 2 +- lib/Chat/Parser/SystemMessage.php | 8 ++++---- lib/Chat/SystemMessage/Listener.php | 8 ++------ lib/Command/Room/Create.php | 15 ++++++++++++++- lib/Command/Room/Update.php | 13 +++++++++++-- lib/Manager.php | 4 ++-- lib/Migration/Version2100Date20201201102528.php | 4 +++- lib/Room.php | 12 ++++++++---- .../ConversationSettings/ModerationSettings.vue | 14 +++++++------- src/constants.js | 2 +- src/store/conversationsStore.js | 2 +- tests/integration/features/bootstrap/FeatureContext.php | 2 +- tests/php/RoomTest.php | 2 +- tests/php/Signaling/BackendNotifierTest.php | 16 ++++++++-------- 15 files changed, 66 insertions(+), 42 deletions(-) diff --git a/docs/chat.md b/docs/chat.md index 736a199f1..2bc58d5ab 100644 --- a/docs/chat.md +++ b/docs/chat.md @@ -160,9 +160,9 @@ Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1` * `call_ended` - Call with {user1}, {user2}, {user3}, {user4} and {user5} (Duration 30:23) * `read_only_off` - {actor} unlocked the conversation * `read_only` - {actor} locked the conversation -* `listable_participants` - {actor} made the conversation listable only for participants +* `listable_none` - {actor} made the conversation listable for nobody * `listable_users` - {actor} made the conversation listable for regular users -* `listable_all` - {actor} made the conversation listable for everone which includes users and guest users +* `listable_all` - {actor} made the conversation listable for everone which includes users and guests * `lobby_timer_reached` - The conversation is now open to everyone * `lobby_none` - {actor} opened the conversation to everyone * `lobby_non_moderators` - {actor} restricted the conversation to moderators diff --git a/docs/constants.md b/docs/constants.md index 8a250c02c..dd4f0e02f 100644 --- a/docs/constants.md +++ b/docs/constants.md @@ -14,7 +14,7 @@ title: Constants ## Listable scope * `0` participants only -* `1` regular users only, excluding guests +* `1` regular users only, excluding guest app users * `2` everyone ## Participant types diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php index 48e9fa1f6..02e1f6b26 100644 --- a/lib/Chat/Parser/SystemMessage.php +++ b/lib/Chat/Parser/SystemMessage.php @@ -165,12 +165,12 @@ class SystemMessage { } elseif ($cliIsActor) { $parsedMessage = $this->l->t('An administrator locked the conversation'); } - } elseif ($message === 'listable_participants') { - $parsedMessage = $this->l->t('{actor} made the conversation listable for participants only'); + } elseif ($message === 'listable_none') { + $parsedMessage = $this->l->t('{actor} made the conversation not listable'); if ($currentUserIsActor) { - $parsedMessage = $this->l->t('You made the conversation listable for participants only'); + $parsedMessage = $this->l->t('You made the conversation not listable'); } elseif ($cliIsActor) { - $parsedMessage = $this->l->t('An administrator made the conversation listable for participants only'); + $parsedMessage = $this->l->t('An administrator made the conversation not listable'); } } elseif ($message === 'listable_users') { $parsedMessage = $this->l->t('{actor} made the conversation listable for users only'); diff --git a/lib/Chat/SystemMessage/Listener.php b/lib/Chat/SystemMessage/Listener.php index 3672aa25e..9642fcab8 100644 --- a/lib/Chat/SystemMessage/Listener.php +++ b/lib/Chat/SystemMessage/Listener.php @@ -179,15 +179,11 @@ class Listener { $dispatcher->addListener(Room::EVENT_AFTER_LISTABLE_SET, static function (ModifyRoomEvent $event) { $room = $event->getRoom(); - if ($room->getType() === Room::CHANGELOG_CONVERSATION) { - return; - } - /** @var self $listener */ $listener = \OC::$server->query(self::class); - if ($event->getNewValue() === Room::LISTABLE_PARTICIPANTS) { - $listener->sendSystemMessage($room, 'listable_participants'); + if ($event->getNewValue() === Room::LISTABLE_NONE) { + $listener->sendSystemMessage($room, 'listable_none'); } elseif ($event->getNewValue() === Room::LISTABLE_USERS) { $listener->sendSystemMessage($room, 'listable_users'); } elseif ($event->getNewValue() === Room::LISTABLE_ALL) { diff --git a/lib/Command/Room/Create.php b/lib/Command/Room/Create.php index eaaae0396..f241fe6b8 100644 --- a/lib/Command/Room/Create.php +++ b/lib/Command/Room/Create.php @@ -110,7 +110,12 @@ class Create extends Base { return 1; } - if (!in_array($listable, [null, '0', '1', '2', '3'], true)) { + if (!in_array($listable, [ + null, + (string)Room::LISTABLE_NONE, + (string)Room::LISTABLE_USERS, + (string)Room::LISTABLE_ALL, + ], true)) { $output->writeln('Invalid value for option "--listable" given.'); return 1; } @@ -167,6 +172,14 @@ class Create extends Base { case 'owner': case 'moderator': return $this->completeParticipantValues($context); + case 'readonly': + return ['1', '0']; + case 'listable': + return [ + (string)Room::LISTABLE_ALL, + (string)Room::LISTABLE_USERS, + (string)Room::LISTABLE_NONE, + ]; } return parent::completeOptionValues($optionName, $context); diff --git a/lib/Command/Room/Update.php b/lib/Command/Room/Update.php index af87053e5..037e7d59a 100644 --- a/lib/Command/Room/Update.php +++ b/lib/Command/Room/Update.php @@ -104,7 +104,12 @@ class Update extends Base { return 1; } - if (!in_array($listable, [null, '0', '1', '2', '3'], true)) { + if (!in_array($listable, [ + null, + (string)Room::LISTABLE_NONE, + (string)Room::LISTABLE_USERS, + (string)Room::LISTABLE_ALL, + ], true)) { $output->writeln('Invalid value for option "--listable" given.'); return 1; } @@ -168,7 +173,11 @@ class Update extends Base { case 'readonly': return ['1', '0']; case 'listable': - return ['2', '1', '0']; + return [ + (string)Room::LISTABLE_ALL, + (string)Room::LISTABLE_USERS, + (string)Room::LISTABLE_NONE, + ]; case 'owner': return $this->completeParticipantValues($context); diff --git a/lib/Manager.php b/lib/Manager.php index e6efc5345..1005931c3 100644 --- a/lib/Manager.php +++ b/lib/Manager.php @@ -758,7 +758,7 @@ class Manager { if ($row === false) { $room = $this->createRoom(Room::CHANGELOG_CONVERSATION, $userId); $room->setReadOnly(Room::READ_ONLY); - $room->setListable(Room::LISTABLE_PARTICIPANTS); + $room->setListable(Room::LISTABLE_NONE); $this->participantService->addUsers($room,[[ 'actorType' => Attendee::ACTOR_USERS, @@ -866,7 +866,7 @@ class Manager { } // FIXME: also check guest user case - if ($room->getListable() === Room::LISTABLE_PARTICIPANTS) { + if ($room->getListable() === Room::LISTABLE_NONE) { try { if ($userId === '') { $sessionId = $this->talkSession->getSessionForRoom($room->getToken()); diff --git a/lib/Migration/Version2100Date20201201102528.php b/lib/Migration/Version2100Date20201201102528.php index b59fcb5d1..b3fd473c0 100644 --- a/lib/Migration/Version2100Date20201201102528.php +++ b/lib/Migration/Version2100Date20201201102528.php @@ -53,8 +53,10 @@ class Version2100Date20201201102528 extends SimpleMigrationStep { 'default' => 0, ]); } + + return $schema; } - return $schema; + return null; } } diff --git a/lib/Room.php b/lib/Room.php index 7a3cf2885..e371631c5 100644 --- a/lib/Room.php +++ b/lib/Room.php @@ -65,10 +65,10 @@ class Room { /** * Only visible when joined */ - public const LISTABLE_PARTICIPANTS = 0; + public const LISTABLE_NONE = 0; /** - * Searchable by all regular users and moderators, even when not joined, excluding guest users + * Searchable by all regular users and moderators, even when not joined, excluding users from the guest app */ public const LISTABLE_USERS = 1; @@ -818,11 +818,15 @@ class Room { return true; } - if (!in_array($this->getType(), [self::GROUP_CALL, self::PUBLIC_CALL, self::CHANGELOG_CONVERSATION], true)) { + if (!in_array($this->getType(), [self::GROUP_CALL, self::PUBLIC_CALL], true)) { return false; } - if ($newState < 0 || $newState > 3) { + if (!in_array($newState, [ + Room::LISTABLE_NONE, + Room::LISTABLE_USERS, + Room::LISTABLE_ALL, + ], true)) { return false; } diff --git a/src/components/ConversationSettings/ModerationSettings.vue b/src/components/ConversationSettings/ModerationSettings.vue index 596e67476..85a93f160 100644 --- a/src/components/ConversationSettings/ModerationSettings.vue +++ b/src/components/ConversationSettings/ModerationSettings.vue @@ -22,19 +22,19 @@