Skip to content

Commit

Permalink
Merge pull request #13490 from nextcloud/feat/add-blur-config
Browse files Browse the repository at this point in the history
feat(call): add option to enable blur background by default for all c…
  • Loading branch information
nickvergessen authored Nov 15, 2024
2 parents f8d770b + 9ea1f70 commit 5b1c701
Show file tree
Hide file tree
Showing 34 changed files with 222 additions and 34 deletions.
1 change: 1 addition & 0 deletions docs/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,4 @@
* `config => chat => summary-threshold` (local) - Number of unread messages that should exist to show a "Generate summary" option
* `config => call => start-without-media` (local) - Boolean, whether media should be disabled when starting or joining a conversation
* `config => call => max-duration` - Integer, maximum call duration in seconds. Please note that this should only be used with system cron and with a reasonable high value, due to the expended duration until the background job ran.
* `config => call => blur-virtual-background` (local) - Boolean, whether blur background is set by default when joining a conversation
15 changes: 8 additions & 7 deletions docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
**Note:** Settings from `calls_start_without_media` onwards can not be set via above API.
Instead, the server API `POST /ocs/v2.php/apps/provisioning_api/api/v1/config/users/{appId}/{configKey}` needs to be used.

| 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) |
| `play_sounds` | | `'yes'` | `'yes'` and `'no'` |
| `calls_start_without_media` | `config => call => start-without-media` | `''` falling back to app config with the same name | `'yes'` and `'no'` |
| 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) |
| `play_sounds` | | `'yes'` | `'yes'` and `'no'` |
| `calls_start_without_media` | `config => call => start-without-media` | `''` falling back to app config with the same name | `'yes'` and `'no'` |
| `blur_virtual_background` | `config => call => blur-virtual-background` | `'no'` | `'yes'` and `'no'` |

## 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 @@ -139,6 +139,7 @@ class Capabilities implements IPublicCapability {
'predefined-backgrounds',
'can-upload-background',
'start-without-media',
'blur-virtual-background',
],
'chat' => [
'read-privacy',
Expand Down Expand Up @@ -212,6 +213,7 @@ public function getCapabilities(): array {
'can-enable-sip' => false,
'start-without-media' => $this->talkConfig->getCallsStartWithoutMedia($user?->getUID()),
'max-duration' => $this->appConfig->getAppValueInt('max_call_duration'),
'blur-virtual-background' => $this->talkConfig->getBlurVirtualBackground($user?->getUID()),
],
'chat' => [
'max-length' => ChatManager::MAX_CHAT_LENGTH,
Expand Down Expand Up @@ -262,6 +264,7 @@ public function getCapabilities(): array {
$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());
$capabilities['config']['call']['blur-virtual-background'] = $this->talkConfig->getBlurVirtualBackground($user->getUID());
}

$pubKey = $this->talkConfig->getSignalingTokenPublicKey();
Expand Down
14 changes: 14 additions & 0 deletions lib/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -680,4 +680,18 @@ public function getCallsStartWithoutMedia(?string $userId): bool {

return $this->appConfig->getAppValueBool('calls_start_without_media');
}

/**
* User setting for blur background
*
* @param ?string $userId
* @return bool
*/
public function getBlurVirtualBackground(?string $userId): bool {
if ($userId !== null) {
$userSetting = $this->config->getUserValue($userId, 'spreed', UserPreference::BLUR_VIRTUAL_BACKGROUND);
return $userSetting === 'yes';
}
return false;
}
}
3 changes: 3 additions & 0 deletions lib/Controller/RoomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,9 @@ public function getCapabilities(): DataResponse {
if (isset($data['config']['call']['start-without-media'])) {
$data['config']['call']['start-without-media'] = $this->talkConfig->getCallsStartWithoutMedia($this->userId);
}
if (isset($data['config']['call']['blur-virtual-background'])) {
$data['config']['call']['blur-virtual-background'] = $this->talkConfig->getBlurVirtualBackground($this->userId);
}

if ($response->getHeaders()['X-Nextcloud-Talk-Hash']) {
$headers['X-Nextcloud-Talk-Proxy-Hash'] = $response->getHeaders()['X-Nextcloud-Talk-Hash'];
Expand Down
3 changes: 3 additions & 0 deletions lib/Federation/Proxy/TalkV1/ProxyRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public function overwrittenRemoteTalkHash(string $hash): string {
'read-privacy',
'typing-privacy',
],
'call' => [
'blur-virtual-background',
]
],
]
]));
Expand Down
1 change: 1 addition & 0 deletions lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@
* can-enable-sip: bool,
* start-without-media: bool,
* max-duration: int,
* blur-virtual-background: bool,
* },
* chat: array{
* max-length: int,
Expand Down
3 changes: 2 additions & 1 deletion lib/Settings/BeforePreferenceSetEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public function validatePreference(string $userId, string $key, string|int|null

// "boolean" yes/no
if ($key === UserPreference::CALLS_START_WITHOUT_MEDIA
|| $key === UserPreference::PLAY_SOUNDS) {
|| $key === UserPreference::PLAY_SOUNDS
|| $key === UserPreference::BLUR_VIRTUAL_BACKGROUND) {
return $value === 'yes' || $value === 'no';
}

Expand Down
1 change: 1 addition & 0 deletions lib/Settings/UserPreference.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OCA\Talk\Settings;

class UserPreference {
public const BLUR_VIRTUAL_BACKGROUND = 'blur_virtual_background';
public const CALLS_START_WITHOUT_MEDIA = 'calls_start_without_media';
public const PLAY_SOUNDS = 'play_sounds';
public const TYPING_PRIVACY = 'typing_privacy';
Expand Down
6 changes: 5 additions & 1 deletion openapi-administration.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@
"sip-dialout-enabled",
"can-enable-sip",
"start-without-media",
"max-duration"
"max-duration",
"blur-virtual-background"
],
"properties": {
"enabled": {
Expand Down Expand Up @@ -195,6 +196,9 @@
"max-duration": {
"type": "integer",
"format": "int64"
},
"blur-virtual-background": {
"type": "boolean"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion openapi-backend-recording.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
"sip-dialout-enabled",
"can-enable-sip",
"start-without-media",
"max-duration"
"max-duration",
"blur-virtual-background"
],
"properties": {
"enabled": {
Expand Down Expand Up @@ -128,6 +129,9 @@
"max-duration": {
"type": "integer",
"format": "int64"
},
"blur-virtual-background": {
"type": "boolean"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion openapi-backend-signaling.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
"sip-dialout-enabled",
"can-enable-sip",
"start-without-media",
"max-duration"
"max-duration",
"blur-virtual-background"
],
"properties": {
"enabled": {
Expand Down Expand Up @@ -128,6 +129,9 @@
"max-duration": {
"type": "integer",
"format": "int64"
},
"blur-virtual-background": {
"type": "boolean"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion openapi-backend-sipbridge.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@
"sip-dialout-enabled",
"can-enable-sip",
"start-without-media",
"max-duration"
"max-duration",
"blur-virtual-background"
],
"properties": {
"enabled": {
Expand Down Expand Up @@ -171,6 +172,9 @@
"max-duration": {
"type": "integer",
"format": "int64"
},
"blur-virtual-background": {
"type": "boolean"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion openapi-bots.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
"sip-dialout-enabled",
"can-enable-sip",
"start-without-media",
"max-duration"
"max-duration",
"blur-virtual-background"
],
"properties": {
"enabled": {
Expand Down Expand Up @@ -128,6 +129,9 @@
"max-duration": {
"type": "integer",
"format": "int64"
},
"blur-virtual-background": {
"type": "boolean"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion openapi-federation.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@
"sip-dialout-enabled",
"can-enable-sip",
"start-without-media",
"max-duration"
"max-duration",
"blur-virtual-background"
],
"properties": {
"enabled": {
Expand Down Expand Up @@ -171,6 +172,9 @@
"max-duration": {
"type": "integer",
"format": "int64"
},
"blur-virtual-background": {
"type": "boolean"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@
"sip-dialout-enabled",
"can-enable-sip",
"start-without-media",
"max-duration"
"max-duration",
"blur-virtual-background"
],
"properties": {
"enabled": {
Expand Down Expand Up @@ -347,6 +348,9 @@
"max-duration": {
"type": "integer",
"format": "int64"
},
"blur-virtual-background": {
"type": "boolean"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@
"sip-dialout-enabled",
"can-enable-sip",
"start-without-media",
"max-duration"
"max-duration",
"blur-virtual-background"
],
"properties": {
"enabled": {
Expand Down Expand Up @@ -288,6 +289,9 @@
"max-duration": {
"type": "integer",
"format": "int64"
},
"blur-virtual-background": {
"type": "boolean"
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions src/__mocks__/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export const mockedCapabilities: Capabilities = {
'can-enable-sip': true,
'start-without-media': false,
'max-duration': 0,
'blur-virtual-background': false,
},
chat: {
'max-length': 32000,
Expand Down Expand Up @@ -152,6 +153,7 @@ export const mockedCapabilities: Capabilities = {
'predefined-backgrounds',
'can-upload-background',
'start-without-media',
'blur-virtual-background',
],
chat: [
'read-privacy',
Expand Down
Loading

0 comments on commit 5b1c701

Please sign in to comment.