Skip to content

Commit

Permalink
Merge pull request #10647 from nextcloud/feat/noid/increase-conversat…
Browse files Browse the repository at this point in the history
…ion-verbose

feat(ConversationSettings): expose conversation settings to non-moderators
  • Loading branch information
Antreesy authored Oct 16, 2023
2 parents 2df8052 + 3a1b3cd commit 8d1b809
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 75 deletions.
2 changes: 1 addition & 1 deletion docs/chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ See [OCP\RichObjectStrings\Definitions](https://github.com/nextcloud/server/blob
* `read_only` - {actor} locked the conversation
* `listable_none` - {actor} limited the conversation to the current participants
* `listable_users` - {actor} opened the conversation accessible to registered users
* `listable_all` - {actor} opened the conversation accessible to registered and guest app users
* `listable_all` - {actor} opened the conversation accessible to registered users and users created with the Guests app
* `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
Expand Down
2 changes: 1 addition & 1 deletion docs/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

### Listable scope
* `0` Participants only
* `1` Regular users only, excluding guest app users
* `1` Regular users only, excluding users created with the Guests app
* `2` Everyone

### Webinar lobby states
Expand Down
6 changes: 3 additions & 3 deletions lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ public function parseMessage(Message $chatMessage): void {
$parsedMessage = $this->l->t('An administrator opened the conversation to registered users');
}
} elseif ($message === 'listable_all') {
$parsedMessage = $this->l->t('{actor} opened the conversation to registered and guest app users');
$parsedMessage = $this->l->t('{actor} opened the conversation to registered users and users created with the Guests app');
if ($currentUserIsActor) {
$parsedMessage = $this->l->t('You opened the conversation to registered and guest app users');
$parsedMessage = $this->l->t('You opened the conversation to registered users and users created with the Guests app');
} elseif ($cliIsActor) {
$parsedMessage = $this->l->t('An administrator opened the conversation to registered and guest app users');
$parsedMessage = $this->l->t('An administrator opened the conversation to registered users and users created with the Guests app');
}
} elseif ($message === 'lobby_timer_reached') {
$parsedMessage = $this->l->t('The conversation is now open to everyone');
Expand Down
3 changes: 1 addition & 2 deletions lib/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1291,8 +1291,7 @@ public function isValidParticipant(string $userId): bool {
}

/**
* Returns whether the given user id is a guest user from
* the guest app
* Returns whether the given user id is a user created with the Guests app
*
* @param string $userId user id to check
* @return bool true if the user is a guest, false otherwise
Expand Down
4 changes: 2 additions & 2 deletions lib/Room.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ class Room {
public const LISTABLE_NONE = 0;

/**
* Searchable by all regular users and moderators, even when not joined, excluding users from the guest app
* Searchable by all regular users and moderators, even when not joined, excluding users created with the Guests app
*/
public const LISTABLE_USERS = 1;

/**
* Searchable by everyone, which includes guest users (from guest app), even when not joined
* Searchable by everyone, which includes users created with the Guests app, even when not joined
*/
public const LISTABLE_ALL = 2;

Expand Down
20 changes: 9 additions & 11 deletions src/components/ConversationSettings/ConversationSettingsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,11 @@
<NotificationsSettings :conversation="conversation" />
</NcAppSettingsSection>

<NcAppSettingsSection v-if="canFullModerate"
id="conversation-settings"
:name="t('spreed', 'Moderation')">
<ListableSettings v-if="!isNoteToSelf" :token="token" />
<LinkShareSettings v-if="!isNoteToSelf" ref="linkShareSettings" />
<ExpirationSettings :token="token" can-full-moderate />
</NcAppSettingsSection>
<NcAppSettingsSection v-else
id="conversation-settings"
:name="t('spreed', 'Setup summary')">
<ExpirationSettings :token="token" />
<NcAppSettingsSection id="conversation-settings"
:name="canFullModerate ? t('spreed', 'Moderation') : t('spreed', 'Setup overview')">
<ListableSettings v-if="!isNoteToSelf && !isGuest" :token="token" :can-full-moderate="canFullModerate" />
<LinkShareSettings v-if="!isNoteToSelf" :token="token" :can-full-moderate="canFullModerate" />
<ExpirationSettings :token="token" :can-full-moderate="canFullModerate" />
</NcAppSettingsSection>

<!-- Meeting: lobby and sip -->
Expand Down Expand Up @@ -177,6 +171,10 @@ export default {
return this.conversation.type === CONVERSATION.TYPE.NOTE_TO_SELF
},

isGuest() {
return this.$store.getters.getActorType() === 'guests'
},

token() {
return this.$store.getters.getConversationSettingsToken()
|| this.$store.getters.getToken()
Expand Down
79 changes: 48 additions & 31 deletions src/components/ConversationSettings/LinkShareSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,25 @@
{{ t('spreed', 'Guest access') }}
</h4>

<NcCheckboxRadioSwitch :checked="isSharedPublicly"
:disabled="isSaving"
type="switch"
aria-describedby="link_share_settings_hint"
@update:checked="toggleGuests">
{{ t('spreed', 'Allow guests to join this conversation via link') }}
</NcCheckboxRadioSwitch>

<NcCheckboxRadioSwitch v-show="isSharedPublicly"
:checked="conversation.hasPassword"
:disabled="isSaving"
type="switch"
aria-describedby="link_share_settings_password_hint"
@update:checked="togglePassword">
{{ t('spreed', 'Password protection') }}
</NcCheckboxRadioSwitch>

<template v-if="showPasswordField">
<form class="password-form"
@submit.prevent="handleSetNewPassword">
<template v-if="canFullModerate">
<NcCheckboxRadioSwitch :checked="isSharedPublicly"
:disabled="isSaving"
type="switch"
aria-describedby="link_share_settings_hint"
@update:checked="toggleGuests">
{{ t('spreed', 'Allow guests to join this conversation via link') }}
</NcCheckboxRadioSwitch>

<NcCheckboxRadioSwitch v-show="isSharedPublicly"
:checked="isPasswordProtectionChecked"
:disabled="isSaving"
type="switch"
aria-describedby="link_share_settings_password_hint"
@update:checked="togglePassword">
{{ t('spreed', 'Password protection') }}
</NcCheckboxRadioSwitch>

<form v-if="showPasswordField" class="password-form" @submit.prevent="handleSetNewPassword">
<NcPasswordField ref="passwordField"
:value.sync="password"
autocomplete="new-password"
Expand All @@ -53,9 +52,7 @@
class="password-form__input-field"
label-visible
:label="t('spreed', 'Enter new password')" />
<NcButton :disabled="isSaving"
type="primary"
native-type="submit">
<NcButton :disabled="isSaving" type="primary" native-type="submit">
<template #icon>
<ArrowRight />
</template>
Expand All @@ -64,19 +61,24 @@
</form>
</template>

<p v-else-if="isSharedPublicly">
{{ t('spreed', 'Guests are allowed to join this conversation via link') }}
</p>
<p v-else>
{{ t('spreed', 'Guests are not allowed to join this conversation') }}
</p>

<div class="app-settings-subsection__buttons">
<NcButton ref="copyLinkButton"
wide
@click="handleCopyLink"
@keydown.enter="handleCopyLink">
<template #icon>
<ClipboardTextOutline />
</template>
{{ t('spreed', 'Copy conversation link') }}
</NcButton>
<NcButton v-if="isSharedPublicly"
<NcButton v-if="isSharedPublicly && canFullModerate"
:disabled="isSendingInvitations"
wide
@click="handleResendInvitations"
@keydown.enter="handleResendInvitations">
<template #icon>
Expand Down Expand Up @@ -115,6 +117,18 @@ export default {
Email,
},

props: {
token: {
type: String,
default: null,
},

canFullModerate: {
type: Boolean,
default: true,
},
},

data() {
return {
// The conversation's password
Expand All @@ -131,13 +145,13 @@ export default {
return this.conversation.type === CONVERSATION.TYPE.PUBLIC
},

token() {
return this.$store.getters.getToken()
},

conversation() {
return this.$store.getters.conversation(this.token) || this.$store.getters.dummyConversation
},

isPasswordProtectionChecked() {
return this.conversation.hasPassword || this.showPasswordField
},
},

methods: {
Expand Down Expand Up @@ -200,7 +214,7 @@ export default {
this.showPasswordField = true
await this.handlePasswordEnable()
this.$nextTick(() => {
this.$refs.passwordField.$el.focus()
this.$refs.passwordField.focus()
})
} else {
this.showPasswordField = false
Expand Down Expand Up @@ -270,5 +284,8 @@ button > .material-design-icon {
display: flex;
gap: 8px;
margin-top: 25px;
& > button {
flex-basis: 50%;
}
}
</style>
73 changes: 53 additions & 20 deletions src/components/ConversationSettings/ListableSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,28 @@
-->

<template>
<div>
<div>
<NcCheckboxRadioSwitch :checked="listable !== LISTABLE.NONE"
:disabled="isListableLoading"
type="switch"
@update:checked="toggleListableUsers">
{{ t('spreed', 'Open conversation to registered users, showing it in search results') }}
</NcCheckboxRadioSwitch>
</div>
<div v-if="listable !== LISTABLE.NONE">
<div v-if="isGuestsAccountsEnabled">
<NcCheckboxRadioSwitch :checked="listable === LISTABLE.ALL"
:disabled="isListableLoading"
type="switch"
@update:checked="toggleListableGuests">
{{ t('spreed', 'Also open to guest app users') }}
</NcCheckboxRadioSwitch>
</div>
</div>
<div v-if="canFullModerate">
<NcCheckboxRadioSwitch :checked="listable !== LISTABLE.NONE"
:disabled="isListableLoading"
type="switch"
@update:checked="toggleListableUsers">
{{ t('spreed', 'Open conversation to registered users, showing it in search results') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch v-if="listable !== LISTABLE.NONE && isGuestsAccountsEnabled"
class="additional-top-margin"
:checked="listable === LISTABLE.ALL"
:disabled="isListableLoading"
type="switch"
@update:checked="toggleListableGuests">
{{ t('spreed', 'Also open to users created with the Guests app') }}
</NcCheckboxRadioSwitch>
</div>

<div v-else>
<h5 class="app-settings-section__subtitle">
{{ t('spreed', 'Open conversation') }}
</h5>
<p>{{ summaryLabel }}</p>
</div>
</template>

Expand All @@ -63,6 +66,11 @@ export default {
default: null,
},

canFullModerate: {
type: Boolean,
default: true,
},

value: {
type: Number,
default: null,
Expand All @@ -85,12 +93,31 @@ export default {
conversation() {
return this.$store.getters.conversation(this.token) || this.$store.getters.dummyConversation
},

summaryLabel() {
switch (this.listable) {
case CONVERSATION.LISTABLE.ALL:
return t('spreed', 'This conversation is open to both registered users and users created with the Guests app')
case CONVERSATION.LISTABLE.USERS:
return t('spreed', 'This conversation is open to registered users')
case CONVERSATION.LISTABLE.NONE:
default:
return t('spreed', 'This conversation is limited to the current participants')
}
}
},

watch: {
value(value) {
this.listable = value
},

conversation: {
immediate: true,
handler() {
this.listable = this.conversation.listable
},
},
},

mounted() {
Expand Down Expand Up @@ -139,7 +166,7 @@ export default {
} else if (listable === CONVERSATION.LISTABLE.USERS) {
this.lastNotification = showSuccess(t('spreed', 'You opened the conversation to registered users'))
} else if (listable === CONVERSATION.LISTABLE.ALL) {
this.lastNotification = showSuccess(t('spreed', 'You opened the conversation to registered and guest app users'))
this.lastNotification = showSuccess(t('spreed', 'You opened the conversation to both registered users and users created with the Guests app'))
}
this.listable = listable
} catch (e) {
Expand All @@ -153,3 +180,9 @@ export default {

}
</script>

<style lang="scss" scoped>
.additional-top-margin {
margin-top: 10px;
}
</style>
4 changes: 2 additions & 2 deletions tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -3024,7 +3024,7 @@ public function allowGuestAccountsCreation(): void {
$this->guestsAppWasEnabled = in_array('guests', $data['apps'], true);

if (!$this->guestsAppWasEnabled) {
// enable guests app
// enable Guests app
/*
$this->sendRequest('POST', '/cloud/apps/guests');
$this->assertStatusCode($this->response, 200);
Expand Down Expand Up @@ -3070,7 +3070,7 @@ public function resetSpreedAppData() {
*/
public function resetGuestsAppState() {
if ($this->guestsAppWasEnabled === null) {
// guests app was not touched
// Guests app was not touched
return;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/php/Chat/Parser/SystemMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,11 @@ public static function dataParseMessage(): array {
['actor' => ['id' => 'actor', 'type' => 'user']],
],
['listable_all', [], 'recipient',
'{actor} opened the conversation to registered and guest app users',
'{actor} opened the conversation to registered users and users created with the Guests app',
['actor' => ['id' => 'actor', 'type' => 'user']],
],
['listable_all', [], 'actor',
'You opened the conversation to registered and guest app users',
'You opened the conversation to registered users and users created with the Guests app',
['actor' => ['id' => 'actor', 'type' => 'user']],
],
['object_shared', ['metaData' => ['id' => 'geo:52.5450511,13.3741463', 'type' => 'geo-location', 'name' => 'Nextcloud Berlin Office']], 'actor',
Expand Down

0 comments on commit 8d1b809

Please sign in to comment.