summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitor Mattos <vitor@php.rio>2023-05-04 12:54:09 -0300
committerVitor Mattos <vitor@php.rio>2023-05-05 05:18:58 -0300
commitd91ce3252490d6a622ec3169d89bd178a18ab2f2 (patch)
tree95bec2b0254912648f187f928510af9592a17f36
parent6070acad9a101fda7682db970352f1d706559a51 (diff)
Add user setting for toggle typing privacy
Signed-off-by: Vitor Mattos <vitor@php.rio>
-rw-r--r--docs/capabilities.md2
-rw-r--r--lib/Capabilities.php2
-rw-r--r--lib/Config.php8
-rw-r--r--tests/php/CapabilitiesTest.php2
4 files changed, 13 insertions, 1 deletions
diff --git a/docs/capabilities.md b/docs/capabilities.md
index 4dbf2c036..9fa2ceb45 100644
--- a/docs/capabilities.md
+++ b/docs/capabilities.md
@@ -119,4 +119,4 @@
* `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 dizable 0 the typing indicator to other users
diff --git a/lib/Capabilities.php b/lib/Capabilities.php
index 8d778540d..84bd18c67 100644
--- a/lib/Capabilities.php
+++ b/lib/Capabilities.php
@@ -134,6 +134,7 @@ class Capabilities implements IPublicCapability {
'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)
@@ -159,6 +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());
}
$pubKey = $this->talkConfig->getSignalingTokenPublicKey();
diff --git a/lib/Config.php b/lib/Config.php
index da5148c3a..093b679c0 100644
--- a/lib/Config.php
+++ b/lib/Config.php
@@ -87,6 +87,14 @@ class Config {
(string) Participant::PRIVACY_PUBLIC);
}
+ public function getTypingPrivacy(string $userId): int {
+ return (int) $this->config->getUserValue(
+ $userId,
+ 'spreed', 'typing_privacy',
+ (string) Participant::PRIVACY_PUBLIC);
+
+ }
+
/**
* @return string[]
*/
diff --git a/tests/php/CapabilitiesTest.php b/tests/php/CapabilitiesTest.php
index 1966e5f4d..1f0a4ef39 100644
--- a/tests/php/CapabilitiesTest.php
+++ b/tests/php/CapabilitiesTest.php
@@ -202,6 +202,7 @@ class CapabilitiesTest extends TestCase {
'max-length' => 32000,
'read-privacy' => 0,
'translations' => [],
+ 'typing-privacy' => 0,
],
'conversations' => [
'can-create' => false,
@@ -325,6 +326,7 @@ class CapabilitiesTest extends TestCase {
'max-length' => 32000,
'read-privacy' => $readPrivacy,
'translations' => [],
+ 'typing-privacy' => 0,
],
'conversations' => [
'can-create' => $canCreate,