Adjustments for listable rooms after review

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
This commit is contained in:
Vincent Petry 2020-12-02 13:55:24 +01:00
Родитель 353206e1e6
Коммит 65238d1b8f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E055D6A4D513575C
15 изменённых файлов: 66 добавлений и 42 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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');

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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('<error>Invalid value for option "--listable" given.</error>');
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);

Просмотреть файл

@ -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('<error>Invalid value for option "--listable" given.</error>');
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);

Просмотреть файл

@ -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());

Просмотреть файл

@ -53,8 +53,10 @@ class Version2100Date20201201102528 extends SimpleMigrationStep {
'default' => 0,
]);
}
return $schema;
}
return $schema;
return null;
}
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -22,19 +22,19 @@
<template>
<div>
<div class="app-settings-subsection">
<div id="moderation_settings_listable_users_hint" class="app-settings-section__hint">
<div id="moderation_settings_listable_conversation_hint" class="app-settings-section__hint">
{{ t('spreed', 'Defines who can find this conversation') }}
</div>
<div>
<label for="moderation_settings_listable_users_conversation_input">{{ t('spreed', 'Listable for') }}</label>
<Multiselect id="moderation_settings_listable_users_conversation_input"
<label for="moderation_settings_listable_conversation_input">{{ t('spreed', 'Listable for') }}</label>
<Multiselect id="moderation_settings_listable_conversation_input"
v-model="listable"
:options="listableOptions"
:placeholder="t('spreed', 'Listable for')"
label="label"
track-by="value"
:disabled="isListableLoading"
aria-describedby="moderation_settings_listable_users_conversation_hint"
aria-describedby="moderation_settings_listable_conversation_hint"
@input="saveListable" />
</div>
</div>
@ -115,9 +115,9 @@ import DatetimePicker from '@nextcloud/vue/dist/Components/DatetimePicker'
import SipSettings from './SipSettings'
const listableOptions = [
{ value: 2, label: t('spreed', 'Everyone') },
{ value: 1, label: t('spreed', 'Regular users, without guests') },
{ value: 0, label: t('spreed', 'Participants only') },
{ value: CONVERSATION.LISTABLE.NONE, label: t('spreed', 'None') },
{ value: CONVERSATION.LISTABLE.USERS, label: t('spreed', 'Registered users') },
{ value: CONVERSATION.LISTABLE.ALL, label: t('spreed', 'Everyone') },
]
export default {

Просмотреть файл

@ -35,7 +35,7 @@ export const CONVERSATION = {
READ_ONLY: 1,
},
LISTABLE: {
PARTICIPANTS: 0,
NONE: 0,
USERS: 1,
ALL: 2,
},

Просмотреть файл

@ -44,7 +44,7 @@ const DUMMY_CONVERSATION = {
participantFlags: PARTICIPANT.CALL_FLAG.DISCONNECTED,
participantType: PARTICIPANT.TYPE.USER,
readOnly: CONVERSATION.STATE.READ_ONLY,
listable: CONVERSATION.LISTABLE.PARTICIPANTS,
listable: CONVERSATION.LISTABLE.NONE,
hasCall: false,
canStartCall: false,
lobbyState: WEBINAR.LOBBY.NONE,

Просмотреть файл

@ -809,7 +809,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
public function userChangesListableScopeOfTheRoom($user, $identifier, $newState, $statusCode, $apiVersion = 'v3') {
$this->setCurrentUser($user);
if ($newState === 'joined') {
$newStateValue = Room::LISTABLE_PARTICIPANTS;
$newStateValue = Room::LISTABLE_NONE;
} elseif ($newState === 'users') {
$newStateValue = Room::LISTABLE_USERS;
} else {

Просмотреть файл

@ -63,7 +63,7 @@ class RoomTest extends TestCase {
1,
Room::PUBLIC_CALL,
Room::READ_WRITE,
Room::LISTABLE_PARTICIPANTS,
Room::LISTABLE_NONE,
Webinary::LOBBY_NONE,
0,
null,

Просмотреть файл

@ -253,7 +253,7 @@ class BackendNotifierTest extends \Test\TestCase {
'lobby-state' => Webinary::LOBBY_NONE,
'lobby-timer' => null,
'read-only' => Room::READ_WRITE,
'listable' => Room::LISTABLE_PARTICIPANTS,
'listable' => Room::LISTABLE_NONE,
'active-since' => null,
'sip-enabled' => 0,
],
@ -289,7 +289,7 @@ class BackendNotifierTest extends \Test\TestCase {
'lobby-state' => Webinary::LOBBY_NONE,
'lobby-timer' => null,
'read-only' => Room::READ_WRITE,
'listable' => Room::LISTABLE_PARTICIPANTS,
'listable' => Room::LISTABLE_NONE,
'active-since' => null,
'sip-enabled' => 0,
],
@ -336,7 +336,7 @@ class BackendNotifierTest extends \Test\TestCase {
'lobby-state' => Webinary::LOBBY_NONE,
'lobby-timer' => null,
'read-only' => Room::READ_WRITE,
'listable' => Room::LISTABLE_PARTICIPANTS,
'listable' => Room::LISTABLE_NONE,
'active-since' => null,
'sip-enabled' => 0,
],
@ -360,7 +360,7 @@ class BackendNotifierTest extends \Test\TestCase {
'lobby-state' => Webinary::LOBBY_NONE,
'lobby-timer' => null,
'read-only' => Room::READ_WRITE,
'listable' => Room::LISTABLE_PARTICIPANTS,
'listable' => Room::LISTABLE_NONE,
'active-since' => null,
'sip-enabled' => 0,
],
@ -384,7 +384,7 @@ class BackendNotifierTest extends \Test\TestCase {
'lobby-state' => Webinary::LOBBY_NONE,
'lobby-timer' => null,
'read-only' => Room::READ_WRITE,
'listable' => Room::LISTABLE_PARTICIPANTS,
'listable' => Room::LISTABLE_NONE,
'active-since' => null,
'sip-enabled' => 0,
],
@ -408,7 +408,7 @@ class BackendNotifierTest extends \Test\TestCase {
'lobby-state' => Webinary::LOBBY_NONE,
'lobby-timer' => null,
'read-only' => Room::READ_ONLY,
'listable' => Room::LISTABLE_PARTICIPANTS,
'listable' => Room::LISTABLE_NONE,
'active-since' => null,
'sip-enabled' => 0,
],
@ -455,7 +455,7 @@ class BackendNotifierTest extends \Test\TestCase {
'lobby-state' => Webinary::LOBBY_NON_MODERATORS,
'lobby-timer' => null,
'read-only' => Room::READ_WRITE,
'listable' => Room::LISTABLE_PARTICIPANTS,
'listable' => Room::LISTABLE_NONE,
'active-since' => null,
'sip-enabled' => 0,
],
@ -615,7 +615,7 @@ class BackendNotifierTest extends \Test\TestCase {
'lobby-state' => Webinary::LOBBY_NONE,
'lobby-timer' => null,
'read-only' => Room::READ_WRITE,
'listable' => Room::LISTABLE_PARTICIPANTS,
'listable' => Room::LISTABLE_NONE,
'active-since' => null,
'sip-enabled' => 0,
'foo' => 'bar',