diff options
author | Vitor Mattos <vitor@php.rio> | 2023-05-04 17:05:24 -0300 |
---|---|---|
committer | Vitor Mattos <vitor@php.rio> | 2023-05-05 05:18:58 -0300 |
commit | 3c62e4a8e35a92bdd14b433193c4ca4f91a18cb6 (patch) | |
tree | 660fd312a7239aa451d90be78d96f6854aec4807 | |
parent | 047ed73a4600a3628198ee7c95d99da9ba982385 (diff) |
Add unit tests and implement pending methods
Signed-off-by: Vitor Mattos <vitor@php.rio>
-rw-r--r-- | docs/constants.md | 4 | ||||
-rw-r--r-- | docs/settings.md | 9 | ||||
-rw-r--r-- | lib/Capabilities.php | 2 | ||||
-rw-r--r-- | lib/Config.php | 2 | ||||
-rw-r--r-- | lib/Controller/SettingsController.php | 4 | ||||
-rw-r--r-- | lib/TInitialState.php | 10 | ||||
-rw-r--r-- | tests/integration/features/chat-2/typing-privacy.feature | 11 |
7 files changed, 36 insertions, 6 deletions
diff --git a/docs/constants.md b/docs/constants.md index 4ea1670cf..68a6abfe5 100644 --- a/docs/constants.md +++ b/docs/constants.md @@ -76,6 +76,10 @@ * `0` Read status is public * `1` Read status is private +### Participant typing privacy +* `0` Make visible the typing status +* `1` Hide the typing status + ### Attendee types * `users` - Logged-in users * `groups` - Groups diff --git a/docs/settings.md b/docs/settings.md index 9b476365e..e4cd4bbd5 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -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 diff --git a/lib/Capabilities.php b/lib/Capabilities.php index 84bd18c67..03ba968da 100644 --- a/lib/Capabilities.php +++ b/lib/Capabilities.php @@ -160,7 +160,7 @@ class Capabilities implements IPublicCapability { 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->getTypingPrivacy($user->getUID()); + $capabilities['config']['chat']['typing-privacy'] = $this->talkConfig->getUserTypingPrivacy($user->getUID()); } $pubKey = $this->talkConfig->getSignalingTokenPublicKey(); diff --git a/lib/Config.php b/lib/Config.php index 093b679c0..4a06bc6b0 100644 --- a/lib/Config.php +++ b/lib/Config.php @@ -87,7 +87,7 @@ class Config { (string) Participant::PRIVACY_PUBLIC); } - public function getTypingPrivacy(string $userId): int { + public function getUserTypingPrivacy(string $userId): int { return (int) $this->config->getUserValue( $userId, 'spreed', 'typing_privacy', diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 2553d1e36..8a7682e00 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -114,6 +114,10 @@ class SettingsController extends OCSController { return false; } + if ($setting === 'typing_privacy') { + return $value === '1' || $value === '0'; + } + if ($setting === 'read_status_privacy') { return (int) $value === Participant::PRIVACY_PUBLIC || (int) $value === Participant::PRIVACY_PRIVATE; diff --git a/lib/TInitialState.php b/lib/TInitialState.php index b02eeecab..cf0d6e489 100644 --- a/lib/TInitialState.php +++ b/lib/TInitialState.php @@ -122,6 +122,11 @@ trait TInitialState { ); $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' ); @@ -191,6 +196,11 @@ trait TInitialState { ); $this->initialState->provideInitialState( + 'typing_privacy', + '0' + ); + + $this->initialState->provideInitialState( 'attachment_folder', '' ); diff --git a/tests/integration/features/chat-2/typing-privacy.feature b/tests/integration/features/chat-2/typing-privacy.feature new file mode 100644 index 000000000..70a7e54ee --- /dev/null +++ b/tests/integration/features/chat-2/typing-privacy.feature @@ -0,0 +1,11 @@ +Feature: chat-2/typing-privacy + Background: + Given user "participant1" exists + Scenario: User toggles the typing privacy + # Hide + 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" + + # Visible + 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" |