Skip to content

Commit f155ff6

Browse files
Merge pull request #19169 from nextcloud/refactor/config/RefactorTalkConfigToAppConfig6
chore(config): recatore next batch of Talk App configs to new AppConfig Framework
2 parents b6ea34a + 4e61f50 commit f155ff6

13 files changed

Lines changed: 80 additions & 51 deletions

File tree

docs/settings.md

Lines changed: 30 additions & 30 deletions
Large diffs are not rendered by default.

lib/BackgroundJob/CheckMatterbridges.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
namespace OCA\Talk\BackgroundJob;
1010

11+
use OCA\Talk\Config;
1112
use OCA\Talk\MatterbridgeManager;
13+
use OCP\AppFramework\Services\IAppConfig;
1214
use OCP\AppFramework\Utility\ITimeFactory;
1315
use OCP\BackgroundJob\IJob;
1416
use OCP\BackgroundJob\TimedJob;
@@ -25,6 +27,7 @@ class CheckMatterbridges extends TimedJob {
2527
public function __construct(
2628
ITimeFactory $time,
2729
private readonly IConfig $serverConfig,
30+
private readonly IAppConfig $appConfig,
2831
private readonly MatterbridgeManager $bridgeManager,
2932
private readonly LoggerInterface $logger,
3033
) {
@@ -38,7 +41,7 @@ public function __construct(
3841

3942
#[\Override]
4043
protected function run($argument): void {
41-
if ($this->serverConfig->getAppValue('spreed', 'enable_matterbridge', '0') === '1') {
44+
if ($this->appConfig->getAppValueBool(Config::MATTERBRIDGE_ENABLED)) {
4245
$this->bridgeManager->checkAllBridges();
4346
$this->bridgeManager->killZombieBridges();
4447
$this->logger->info('Checked if Matterbridge instances are running correctly.');

lib/Config.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class Config {
4848
public const string ALLOWED_GROUPS_CONVERSATIONS = 'start_conversations';
4949
public const string BREAKOUT_ROOMS_ENABLED = 'breakout_rooms';
5050
public const string CONVERSATION_SUBFOLDERS = 'conversation_subfolders';
51+
public const string CONVERSATIONS_FILES = 'conversations_files';
52+
public const string CONVERSATIONS_FILES_PUBLIC_SHARES = 'conversations_files_public_shares';
5153
public const string DEFAULT_ROOM_PERMISSIONS = 'default_permissions';
5254
public const string DEFAULT_ATTACHMENT_FOLDER = 'default_attachment_folder';
5355
public const string GRID_VIDEOS_LIMIT = 'grid_videos_limit';
@@ -66,6 +68,13 @@ class Config {
6668
public const string EXPERIMENTS_USERS = 'experiments_users';
6769
public const string EXPERIMENTS_GUESTS = 'experiments_guests';
6870
public const string CALL_END_TO_END_ENCRYPTION = 'call_end_to_end_encryption';
71+
public const string FORCE_PASSWORDS = 'force_passwords';
72+
public const string BACKGROUNDS_BRANDED_FOR_GUESTS = 'backgrounds_branded_for_guests';
73+
public const string BACKGROUNDS_DEFAULT_FOR_USERS = 'backgrounds_default_for_useres';
74+
public const string BACKGROUNDS_UPLOAD_USERS = 'backgrounds_upload_users';
75+
public const string CREATE_SAMPLES = 'create_samples';
76+
public const string MATTERBRIDGE_ENABLED = 'enable_matterbridge';
77+
public const string DELETE_ONE_TO_ONE_CONVERSATIONS = 'delete_one_to_one_conversations';
6978

7079
/**
7180
* 1. Call recording, …
@@ -1019,7 +1028,7 @@ public function hasExperiment(int $experiment): bool {
10191028
}
10201029

10211030
public function isPasswordEnforced(): bool {
1022-
return $this->appConfig->getAppValueBool('force_passwords');
1031+
return $this->appConfig->getAppValueBool(self::FORCE_PASSWORDS);
10231032
}
10241033

10251034
public function isCallEndToEndEncryptionEnabled(): bool {
@@ -1039,6 +1048,6 @@ public function getPlaySoundsForUser(?IUser $user): bool {
10391048
}
10401049

10411050
public function getPlaySoundsDefaultForGuests(): bool {
1042-
return $this->appConfig->getAppValueBool('guests_play_sounds', true);
1051+
return $this->appConfig->getAppValueBool(self::GUESTS_PLAY_SOUNDS);
10431052
}
10441053
}

lib/ConfigLexicon.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public function getAppConfigs(): array {
3737
new Entry(Config::ALLOWED_GROUPS_CONVERSATIONS, ValueType::ARRAY, [], definition: 'List of group ids that are allowed to create conversation'),
3838
new Entry(Config::BREAKOUT_ROOMS_ENABLED, ValueType::BOOL, true, definition: 'Whether or not breakout rooms are allowed (Will only prevent creating new breakout rooms. Existing conversations are not modified.'),
3939
new Entry(Config::CONVERSATION_SUBFOLDERS, ValueType::BOOL, true, definition: ''),
40+
new Entry(Config::CONVERSATIONS_FILES, ValueType::BOOL, true, definition: 'Whether the files app integration is enabled allowing tostart conversations in the right sidebar'),
41+
new Entry(Config::CONVERSATIONS_FILES_PUBLIC_SHARES, ValueType::BOOL, true, definition: 'Whether the public share integration is enabled allowing to start conversations in the right sidebar on the public share page (Requires `conversations_files` also to be enabled'),
4042
new Entry(Config::DEFAULT_ROOM_PERMISSIONS, ValueType::INT, 246, definition: 'Default permissions for non-moderators' . PHP_EOL . '(see https://github.com/nextcloud/spreed/blob/main/docs/constants.md#attendee-permissions for bit flags)'),
4143
new Entry(Config::DEFAULT_ATTACHMENT_FOLDER, ValueType::STRING, '/Talk', definition: 'Specify default attachment folder location'),
4244
new Entry(Config::GRID_VIDEOS_LIMIT, ValueType::INT, 19 /* 5*4 - self */, definition: 'Maximum number of videos to show (additional to the own video)'),
@@ -50,11 +52,18 @@ public function getAppConfigs(): array {
5052
new Entry(Config::EXTERNAL_CALL_SERVICE_FRAME_ORIGINS, ValueType::ARRAY, [], definition: 'JSON array of scheme+host(+port) origins that may be loaded in the iframe.' . PHP_EOL . 'Added to `Content-Security-Policy: frame-src` and the `Permissions-Policy` for camera/microphone'),
5153
new Entry(Config::EXTERNAL_CALL_SERVICE_IFRAME_FIELD, ValueType::STRING, '', definition: 'JSON field name in the external service response that contains the iframe URL'),
5254
new Entry(Config::CALLS_START_WITHOUT_MEDIA, ValueType::BOOL, false, definition: 'Whether participants start with enabled or disabled audio and video by default'),
53-
new Entry(Config::INACTIVITY_LOCK_AFTER_DAYS, ValueType::INT, 0, definition: 'A duration (in days) after which rooms are locked. Calculated from the last activity in the room,'),
55+
new Entry(Config::INACTIVITY_LOCK_AFTER_DAYS, ValueType::INT, 0, definition: 'A duration (in days) after which rooms are locked. Calculated from the last activity in the room.'),
5456
new Entry(Config::INACTIVITY_ENABLE_LOBBY, ValueType::BOOL, false, definition: 'Additionally enable the lobby for inactive rooms so they can only be read by moderators.'),
5557
new Entry(Config::EXPERIMENTS_USERS, ValueType::INT, 0, definition: 'Bit flag of experiments that should be enabled for logged-in users on this server' . PHP_EOL . 'See https://github.com/nextcloud/spreed/blob/main/docs/settings.md#experiments'),
5658
new Entry(Config::EXPERIMENTS_GUESTS, ValueType::INT, 0, definition: 'Bit flag of experiments that should be enabled for guests on this server' . PHP_EOL . 'See https://github.com/nextcloud/spreed/blob/main/docs/settings.md#experiments'),
5759
new Entry(Config::CALL_END_TO_END_ENCRYPTION, ValueType::BOOL, false, definition: 'Whether clients should end-to-end encrypt streams in calls (Only supported with High-performance backend'),
60+
new Entry(Config::FORCE_PASSWORDS, ValueType::BOOL, false, definition: 'Whether public chats are forced to use a password'),
61+
new Entry(Config::BACKGROUNDS_BRANDED_FOR_GUESTS, ValueType::BOOL, false, definition: 'Whether guests are allowed to use the virtual backgrounds provided via `themes/talk-backgrounds/`'),
62+
new Entry(Config::BACKGROUNDS_DEFAULT_FOR_USERS, ValueType::BOOL, definition: 'Whether users are allowed to use the default virutal backgrounds provided by the releases'),
63+
new Entry(Config::BACKGROUNDS_UPLOAD_USERS, ValueType::BOOL, definition: 'Whether users are allowed to upload custom virtual backgrounds and choose from their Nextcloud Files'),
64+
new Entry(Config::CREATE_SAMPLES, ValueType::BOOL, true, definition: 'Create sample conversations (the content can be overwritten by providing files in a provided `samples_directory` app config)'),
65+
new Entry(Config::MATTERBRIDGE_ENABLED, ValueType::BOOL, false, definition: 'Whether the Matterbridge integration is enabled and can be configured'),
66+
new Entry(Config::DELETE_ONE_TO_ONE_CONVERSATIONS, ValueType::BOOL, false, definition: 'Whether one-to-one conversations can be left by either participant or should be deleted when one participant leaves'),
5867
];
5968
}
6069

lib/Controller/ChatController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1860,7 +1860,7 @@ public function clearHistory(): DataResponse {
18601860
return new DataResponse(null, Http::STATUS_FORBIDDEN);
18611861
}
18621862

1863-
if (!$this->appConfig->getAppValueBool('delete_one_to_one_conversations')
1863+
if (!$this->appConfig->getAppValueBool(Config::DELETE_ONE_TO_ONE_CONVERSATIONS)
18641864
&& ($this->room->getType() === Room::TYPE_ONE_TO_ONE
18651865
|| $this->room->getType() === Room::TYPE_ONE_TO_ONE_FORMER)) {
18661866
// Not allowed to purge one-to-one conversations

lib/Controller/FilesIntegrationController.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace OCA\Talk\Controller;
1010

11+
use OCA\Talk\Config;
1112
use OCA\Talk\Exceptions\RoomNotFoundException;
1213
use OCA\Talk\Files\Util;
1314
use OCA\Talk\Manager;
@@ -24,6 +25,7 @@
2425
use OCP\AppFramework\OCS\OCSException;
2526
use OCP\AppFramework\OCS\OCSNotFoundException;
2627
use OCP\AppFramework\OCSController;
28+
use OCP\AppFramework\Services\IAppConfig;
2729
use OCP\Files\FileInfo;
2830
use OCP\Files\NotFoundException;
2931
use OCP\IConfig;
@@ -48,6 +50,7 @@ public function __construct(
4850
private readonly TalkSession $talkSession,
4951
private readonly Util $util,
5052
private readonly IConfig $config,
53+
private readonly IAppConfig $appConfig,
5154
private readonly IL10N $l,
5255
) {
5356
parent::__construct($appName, $request);
@@ -89,7 +92,7 @@ public function __construct(
8992
'fileId' => '.+',
9093
])]
9194
public function getRoomByFileId(string $fileId): DataResponse {
92-
if ($this->config->getAppValue('spreed', 'conversations_files', '1') !== '1') {
95+
if (!$this->appConfig->getAppValueBool(Config::CONVERSATIONS_FILES)) {
9396
return new DataResponse(null, Http::STATUS_BAD_REQUEST);
9497
}
9598

@@ -167,8 +170,8 @@ public function getRoomByFileId(string $fileId): DataResponse {
167170
'shareToken' => '.+',
168171
])]
169172
public function getRoomByShareToken(string $shareToken): DataResponse {
170-
if ($this->config->getAppValue('spreed', 'conversations_files', '1') !== '1'
171-
|| $this->config->getAppValue('spreed', 'conversations_files_public_shares', '1') !== '1') {
173+
if (!$this->appConfig->getAppValueBool(Config::CONVERSATIONS_FILES)
174+
|| !$this->appConfig->getAppValueBool(Config::CONVERSATIONS_FILES_PUBLIC_SHARES)) {
172175
return new DataResponse(null, Http::STATUS_BAD_REQUEST);
173176
}
174177

lib/Controller/RoomController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ protected function getTalkHashHeader(): array {
196196
$this->appConfig->getAppValueInt(Config::DEFAULT_ROOM_PERMISSIONS),
197197
$this->appConfig->getAppValueBool(Config::BREAKOUT_ROOMS_ENABLED),
198198
$this->config->getAppValue('spreed', 'federation_enabled'),
199-
$this->config->getAppValue('spreed', 'enable_matterbridge'),
200199
json_encode($this->appConfig->getAppValueArray(Config::ALLOWED_GROUPS_SIP)),
200+
$this->appConfig->getAppValueBool(Config::MATTERBRIDGE_ENABLED),
201201
$this->config->getAppValue('spreed', 'sip_bridge_dialin_info'),
202202
$this->config->getAppValue('spreed', 'sip_bridge_shared_secret'),
203203
$this->config->getAppValue('spreed', 'recording_consent'),
@@ -1132,7 +1132,7 @@ public function deleteRoom(): DataResponse {
11321132
return new DataResponse(['error' => 'preserved'], Http::STATUS_FORBIDDEN);
11331133
}
11341134

1135-
if (!$this->appConfig->getAppValueBool('delete_one_to_one_conversations')
1135+
if (!$this->appConfig->getAppValueBool(Config::DELETE_ONE_TO_ONE_CONVERSATIONS)
11361136
&& in_array($this->room->getType(), [Room::TYPE_ONE_TO_ONE, Room::TYPE_ONE_TO_ONE_FORMER], true)) {
11371137
return new DataResponse(null, Http::STATUS_BAD_REQUEST);
11381138
}
@@ -1734,7 +1734,7 @@ protected function removeSelfFromRoomLogic(Room $room, Participant $participant)
17341734
return new DataResponse(null);
17351735
}
17361736

1737-
if ($this->appConfig->getAppValueBool('delete_one_to_one_conversations')
1737+
if ($this->appConfig->getAppValueBool(Config::DELETE_ONE_TO_ONE_CONVERSATIONS)
17381738
&& in_array($this->room->getType(), [Room::TYPE_ONE_TO_ONE, Room::TYPE_ONE_TO_ONE_FORMER], true)) {
17391739
$this->roomService->deleteRoom($room);
17401740
return new DataResponse(null);

lib/Files/TemplateLoader.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use OCA\Files\Event\LoadSidebar;
1212
use OCA\Talk\AppInfo\Application;
1313
use OCA\Talk\Config;
14+
use OCP\AppFramework\Services\IAppConfig;
1415
use OCP\AppFramework\Services\IInitialState;
1516
use OCP\EventDispatcher\Event;
1617
use OCP\EventDispatcher\IEventListener;
@@ -30,6 +31,7 @@ public function __construct(
3031
private readonly IInitialState $initialState,
3132
private readonly Config $talkConfig,
3233
private readonly IConfig $serverConfig,
34+
private readonly IAppConfig $appConfig,
3335
private readonly IUserSession $userSession,
3436
private readonly IRequest $request,
3537
) {
@@ -49,7 +51,7 @@ public function handle(Event $event): void {
4951
return;
5052
}
5153

52-
if ($this->serverConfig->getAppValue('spreed', 'conversations_files', '1') !== '1') {
54+
if (!$this->appConfig->getAppValueBool(Config::CONVERSATIONS_FILES)) {
5355
return;
5456
}
5557

lib/PublicShare/TemplateLoader.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent;
1313
use OCA\Talk\AppInfo\Application;
1414
use OCA\Talk\Config;
15+
use OCP\AppFramework\Services\IAppConfig;
1516
use OCP\AppFramework\Services\IInitialState;
1617
use OCP\EventDispatcher\Event;
1718
use OCP\EventDispatcher\IEventListener;
@@ -31,6 +32,7 @@ public function __construct(
3132
private readonly IInitialState $initialState,
3233
private readonly Config $talkConfig,
3334
private readonly IConfig $serverConfig,
35+
private readonly IAppConfig $appConfig,
3436
) {
3537
}
3638

@@ -49,8 +51,8 @@ public function handle(Event $event): void {
4951
return;
5052
}
5153

52-
if ($this->serverConfig->getAppValue('spreed', 'conversations_files', '1') !== '1'
53-
|| $this->serverConfig->getAppValue('spreed', 'conversations_files_public_shares', '1') !== '1') {
54+
if (!$this->appConfig->getAppValueBool(Config::CONVERSATIONS_FILES)
55+
|| !$this->appConfig->getAppValueBool(Config::CONVERSATIONS_FILES_PUBLIC_SHARES)) {
5456
return;
5557
}
5658

lib/Service/SampleConversationsService.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use OCA\Talk\Chat\ChatManager;
1212
use OCA\Talk\Chat\ReactionManager;
13+
use OCA\Talk\Config;
1314
use OCA\Talk\Model\Attendee;
1415
use OCA\Talk\Room;
1516
use OCP\AppFramework\Services\IAppConfig;
@@ -44,7 +45,7 @@ public function __construct(
4445
}
4546

4647
public function initialCreateSamples(string $userId): void {
47-
if (!$this->appConfig->getAppValueBool('create_samples', true)) {
48+
if (!$this->appConfig->getAppValueBool(Config::CREATE_SAMPLES, true)) {
4849
return;
4950
}
5051

0 commit comments

Comments
 (0)