Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user setting for toggle typing privacy #9455

Merged
merged 6 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,5 @@
* `config => call => predefined-backgrounds` - List of predefined virtual backgrounds. The files are in Talks img/ folder, accessible via the normal image path methods. The list is cached for 5 minutes.
* `config => call => can-upload-background` - Boolean flag whether the user can upload a custom virtual background (requires an account and non-zero quota). Uploads should be done to Talk/Backgrounds/ (respecting the user's attachment directory setting).
* `config => call => supported-reactions` - A list of emojis supported as call reactions. If the list is absent or empty, clients should not show the emoji reaction option in calls.
*
* `config => chat => typing-privacy` - User defined numeric value to enable 1 or disable 0 the typing indicator to other users
* `typing-privacy` - Support toggle typing privacy
4 changes: 4 additions & 0 deletions docs/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
* `0` Read status is public
* `1` Read status is private

### Participant typing privacy
* `0` Typing status is public
* `1` Typing status is private

### Attendee types
* `users` - Logged-in users
* `groups` - Groups
Expand Down
9 changes: 5 additions & 4 deletions docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@

## User settings

| Key | Capability | Default | Valid values |
|-----------------------|-----------------------------------|-------------------------------------------------|----------------------------------------------------------------------------------------------------------|
| `attachment_folder` | `config => attachments => folder` | Value of app config `default_attachment_folder` | Path owned by the user to store uploads and received shares. It is created if it does not exist. |
| `read_status_privacy` | `config => chat => read-privacy` | `0` | One of the read-status constants from the [constants list](constants.md#participant-read-status-privacy) |
| Key | Capability | Default | Valid values |
|-----------------------|------------------------------------|-------------------------------------------------|----------------------------------------------------------------------------------------------------------|
| `attachment_folder` | `config => attachments => folder` | Value of app config `default_attachment_folder` | Path owned by the user to store uploads and received shares. It is created if it does not exist. |
| `read_status_privacy` | `config => chat => read-privacy` | `0` | One of the read-status constants from the [constants list](constants.md#participant-read-status-privacy) |
| `typing_privacy` | `config => chat => typing-privacy` | `0` | One of the typing privacy constants from the [constants list](constants.md#participant-typing-privacy) |

## Set SIP settings

Expand Down
3 changes: 3 additions & 0 deletions lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public function getCapabilities(): array {
'chat-get-context',
'single-conversation-status',
'chat-keep-notifications',
'typing-privacy',
],
'config' => [
'attachments' => [
Expand All @@ -134,6 +135,7 @@ public function getCapabilities(): array {
'read-privacy' => Participant::PRIVACY_PUBLIC,
// Transform the JsonSerializable language tuples to arrays
'translations' => json_decode(json_encode($this->translationManager->getLanguages()), true),
'typing-privacy' => Participant::PRIVACY_PUBLIC,
],
'conversations' => [
'can-create' => $user instanceof IUser && !$this->talkConfig->isNotAllowedToCreateConversations($user)
Expand All @@ -159,6 +161,7 @@ public function getCapabilities(): array {
if ($user instanceof IUser) {
$capabilities['config']['attachments']['folder'] = $this->talkConfig->getAttachmentFolder($user->getUID());
$capabilities['config']['chat']['read-privacy'] = $this->talkConfig->getUserReadPrivacy($user->getUID());
$capabilities['config']['chat']['typing-privacy'] = $this->talkConfig->getUserTypingPrivacy($user->getUID());
}

$pubKey = $this->talkConfig->getSignalingTokenPublicKey();
Expand Down
8 changes: 8 additions & 0 deletions lib/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ public function getUserReadPrivacy(string $userId): int {
(string) Participant::PRIVACY_PUBLIC);
}

public function getUserTypingPrivacy(string $userId): int {
return (int) $this->config->getUserValue(
$userId,
'spreed', 'typing_privacy',
(string) Participant::PRIVACY_PUBLIC);

}

/**
* @return string[]
*/
Expand Down
1 change: 0 additions & 1 deletion lib/Controller/AvatarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
namespace OCA\Talk\Controller;

use InvalidArgumentException;
use OCA\Mail\Service\Avatar\Avatar;
use OCA\Talk\Middleware\Attribute\RequireModeratorParticipant;
use OCA\Talk\Middleware\Attribute\RequireParticipant;
use OCA\Talk\Service\AvatarService;
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected function validateUserSetting(string $setting, $value): bool {
return false;
}

if ($setting === 'read_status_privacy') {
if ($setting === 'typing_privacy' || $setting === 'read_status_privacy') {
return (int) $value === Participant::PRIVACY_PUBLIC ||
(int) $value === Participant::PRIVACY_PRIVATE;
}
Expand Down
10 changes: 10 additions & 0 deletions lib/TInitialState.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ protected function publishInitialStateForUser(IUser $user, IRootFolder $rootFold
$this->talkConfig->getUserReadPrivacy($user->getUID())
);

$this->initialState->provideInitialState(
'typing_privacy',
$this->talkConfig->getUserTypingPrivacy($user->getUID())
);

$this->initialState->provideInitialState(
'play_sounds',
$this->serverConfig->getUserValue($user->getUID(), 'spreed', 'play_sounds', 'yes') === 'yes'
Expand Down Expand Up @@ -190,6 +195,11 @@ protected function publishInitialStateForGuest(): void {
Participant::PRIVACY_PUBLIC
);

$this->initialState->provideInitialState(
'typing_privacy',
Participant::PRIVACY_PUBLIC
);

$this->initialState->provideInitialState(
'attachment_folder',
''
Expand Down
11 changes: 11 additions & 0 deletions tests/integration/features/chat-2/typing-privacy.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Feature: chat-2/typing-privacy
Background:
Given user "participant1" exists
Scenario: User toggles the typing privacy
# Private
When user "participant1" sets setting "typing_privacy" to "1" with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>typing-privacy" set to "1"

# Public
When user "participant1" sets setting "typing_privacy" to "0" with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>typing-privacy" set to "0"
3 changes: 3 additions & 0 deletions tests/php/CapabilitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public function setUp(): void {
'chat-get-context',
'single-conversation-status',
'chat-keep-notifications',
'typing-privacy',
'message-expiration',
'reactions',
];
Expand Down Expand Up @@ -202,6 +203,7 @@ public function testGetCapabilitiesGuest(): void {
'max-length' => 32000,
'read-privacy' => 0,
'translations' => [],
'typing-privacy' => 0,
],
'conversations' => [
'can-create' => false,
Expand Down Expand Up @@ -325,6 +327,7 @@ public function testGetCapabilitiesUserAllowed(bool $isNotAllowed, bool $canCrea
'max-length' => 32000,
'read-privacy' => $readPrivacy,
'translations' => [],
'typing-privacy' => 0,
],
'conversations' => [
'can-create' => $canCreate,
Expand Down