Skip to content

Commit 42e0247

Browse files
committed
chore(config): refactor federation configs to new AppConfig
Signed-off-by: Christian Lorang <christian.lorang@nextcloud.com>
1 parent 2d4c8b0 commit 42e0247

16 files changed

Lines changed: 37 additions & 33 deletions

docs/developer-setup.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ The provided `docker-compose.yml` file from `nextcloud-docker-dev` supports spin
175175
176176
6. Enable federation in the admin settings of Nextcloud Talk or alternatively via occ:
177177
178-
./scripts/occ.sh nextcloud -- config:app:set spreed federation_enabled --value yes
179-
./scripts/occ.sh nextcloud2 -- config:app:set spreed federation_enabled --value yes
178+
./scripts/occ.sh nextcloud -- config:app:set spreed federation_enabled --value true --type boolean
179+
./scripts/occ.sh nextcloud2 -- config:app:set spreed federation_enabled --value true --type boolean
180180
181181
### Rebuild / update Talk after code changes
182182

lib/AppInfo/Application.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
use OCP\AppFramework\Bootstrap\IBootContext;
139139
use OCP\AppFramework\Bootstrap\IBootstrap;
140140
use OCP\AppFramework\Bootstrap\IRegistrationContext;
141+
use OCP\AppFramework\Services\IAppConfig;
141142
use OCP\Calendar\Events\CalendarObjectCreatedEvent;
142143
use OCP\Calendar\Events\CalendarObjectUpdatedEvent;
143144
use OCP\Collaboration\AutoComplete\AutoCompleteFilterEvent;
@@ -152,7 +153,6 @@
152153
use OCP\Group\Events\GroupDeletedEvent;
153154
use OCP\Group\Events\UserAddedEvent;
154155
use OCP\Group\Events\UserRemovedEvent;
155-
use OCP\IConfig;
156156
use OCP\INavigationManager;
157157
use OCP\IURLGenerator;
158158
use OCP\IUser;
@@ -433,10 +433,10 @@ public function registerNavigationLink(INavigationManager $navigationManager): v
433433
}
434434

435435
public function registerCloudFederationProviderManager(
436-
IConfig $config,
436+
IAppConfig $appConfig,
437437
ICloudFederationProviderManager $manager,
438438
): void {
439-
if ($config->getAppValue('spreed', 'federation_enabled', 'no') !== 'yes') {
439+
if ($appConfig->getAppValueBool(Config::FEDERATION_ENABLED)) {
440440
return;
441441
}
442442

lib/Config.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class Config {
4242
public const string ALLOWED_GROUPS_TALK = 'allowed_groups';
4343
public const string ALLOWED_GROUPS_SIP = 'sip_bridge_groups';
4444
public const string ALLOWED_GROUPS_CONVERSATIONS = 'start_conversations';
45+
public const string ALLOWED_GROUPS_FEDERATION = 'federation_allowed_groups';
46+
public const string FEDERATION_ENABLED = 'federation_enabled';
4547
public const string BREAKOUT_ROOMS_ENABLED = 'breakout_rooms';
4648
public const string CONVERSATION_SUBFOLDERS = 'conversation_subfolders';
4749
public const string DEFAULT_ROOM_PERMISSIONS = 'default_permissions';
@@ -128,11 +130,11 @@ public function isSIPConfigured(): bool {
128130
*/
129131
public function isFederationEnabled(): bool {
130132
// TODO: Set to default true once implementation is complete
131-
return $this->config->getAppValue('spreed', 'federation_enabled', 'no') === 'yes';
133+
return $this->appConfig->getAppValueBool(self::FEDERATION_ENABLED);
132134
}
133135

134136
public function isFederationEnabledForUserId(IUser $user): bool {
135-
$allowedGroups = $this->appConfig->getAppValueArray('federation_allowed_groups', lazy: true);
137+
$allowedGroups = $this->appConfig->getAppValueArray(self::ALLOWED_GROUPS_FEDERATION, lazy: true);
136138
if (empty($allowedGroups)) {
137139
return true;
138140
}

lib/ConfigLexicon.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public function getAppConfigs(): array {
3131
new Entry(Config::ALLOWED_GROUPS_TALK, ValueType::ARRAY, [], definition: 'List of group ids that are allowed to use Talk'),
3232
new Entry(Config::ALLOWED_GROUPS_SIP, ValueType::ARRAY, [], definition: 'List of group ids that are allowed to enable SIP dial-in in a conversation'),
3333
new Entry(Config::ALLOWED_GROUPS_CONVERSATIONS, ValueType::ARRAY, [], definition: 'List of group ids that are allowed to create conversation'),
34+
new Entry(Config::ALLOWED_GROUPS_FEDERATION, ValueType::ARRAY, [], definition: 'List of local group ids that are allowed to use federated features'),
35+
new Entry(Config::FEDERATION_ENABLED, ValueType::BOOL, false, definition: 'Whether or not federation with this instance is allowed'),
3436
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.'),
3537
new Entry(Config::CONVERSATION_SUBFOLDERS, ValueType::BOOL, true, definition: ''),
3638
new Entry(Config::DEFAULT_ROOM_PERMISSIONS, ValueType::INT, 246, definition: 'Default permissions for non-moderators (see [constants list](constants.md#attendee-permissions) for bit flags)'),

lib/Controller/RoomController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ protected function getTalkHashHeader(): array {
191191
implode(',', $this->appConfig->getAppValueArray(Config::ALLOWED_GROUPS_CONVERSATIONS)),
192192
$this->appConfig->getAppValueInt(Config::DEFAULT_ROOM_PERMISSIONS),
193193
$this->appConfig->getAppValueBool(Config::BREAKOUT_ROOMS_ENABLED),
194-
$this->config->getAppValue('spreed', 'federation_enabled'),
194+
$this->appConfig->getAppValueBool(Config::FEDERATION_ENABLED),
195195
$this->config->getAppValue('spreed', 'enable_matterbridge'),
196196
implode(',', $this->appConfig->getAppValueArray(Config::ALLOWED_GROUPS_SIP)),
197197
$this->config->getAppValue('spreed', 'sip_bridge_dialin_info'),
@@ -204,7 +204,7 @@ protected function getTalkHashHeader(): array {
204204
$this->config->getAppValue('spreed', 'federation_incoming_enabled'),
205205
$this->config->getAppValue('spreed', 'federation_outgoing_enabled'),
206206
$this->config->getAppValue('spreed', 'federation_only_trusted_servers'),
207-
$this->config->getAppValue('spreed', 'federation_allowed_groups', '[]'),
207+
implode(',', $this->appConfig->getAppValueArray(Config::ALLOWED_GROUPS_FEDERATION)),
208208
$this->appConfig->getAppValueInt('feature_hints_hidden'),
209209
];
210210

lib/Settings/Admin/AdminSettings.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ protected function initAllowedGroups(): void {
9090
}
9191

9292
protected function initFederation(): void {
93-
$this->initialState->provideInitialState('federation_enabled', $this->talkConfig->isFederationEnabled());
93+
$this->initialState->provideInitialState(Config::FEDERATION_ENABLED, $this->talkConfig->isFederationEnabled());
9494
$this->initialState->provideInitialState('federation_incoming_enabled', $this->appConfig->getAppValueBool('federation_incoming_enabled', true));
9595
$this->initialState->provideInitialState('federation_outgoing_enabled', $this->appConfig->getAppValueBool('federation_outgoing_enabled', true));
9696
$this->initialState->provideInitialState('federation_only_trusted_servers', $this->appConfig->getAppValueBool('federation_only_trusted_servers'));
97-
$this->initialState->provideInitialState('federation_allowed_groups', $this->appConfig->getAppValueArray('federation_allowed_groups'));
97+
$this->initialState->provideInitialState(Config::ALLOWED_GROUPS_FEDERATION, $this->appConfig->getAppValueArray(Config::ALLOWED_GROUPS_FEDERATION));
9898
}
9999

100100
protected function initMatterbridge(): void {

tests/integration/features/federation/call.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ Feature: federation/call
44
Given using server "REMOTE"
55
And user "participant2" exists
66
And the following "spreed" app config is set
7-
| federation_enabled | yes |
7+
| federation_enabled | true |
88
And using server "LOCAL"
99
And user "participant1" exists
1010
And the following "spreed" app config is set
11-
| federation_enabled | yes |
11+
| federation_enabled | true |
1212

1313
Scenario: join call
1414
Given user "participant1" creates room "room" (v4)

tests/integration/features/federation/chat.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ Feature: federation/chat
44
And user "participant2" exists
55
And user "participant3" exists
66
And the following "spreed" app config is set
7-
| federation_enabled | yes |
7+
| federation_enabled | true |
88
And using server "LOCAL"
99
Given user "participant1" exists
1010
Given user "participant2" exists
1111
Given user "participant3" exists
1212
And the following "spreed" app config is set
13-
| federation_enabled | yes |
13+
| federation_enabled | true |
1414

1515
Scenario: Get mention suggestions (translating local users to federated users)
1616
Given user "participant1" creates room "room" (v4)

tests/integration/features/federation/invite.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ Feature: federation/invite
33
Given using server "REMOTE"
44
Given user "participant2" exists
55
And the following "spreed" app config is set
6-
| federation_enabled | yes |
6+
| federation_enabled | true |
77
Given using server "LOCAL"
88
Given user "participant1" exists
99
And the following "spreed" app config is set
10-
| federation_enabled | yes |
10+
| federation_enabled | true |
1111

1212
Scenario: Federation is disabled
1313
Given the following "spreed" app config is set
14-
| federation_enabled | no |
14+
| federation_enabled | false |
1515
Given user "participant1" creates room "room" (v4)
1616
| roomType | 3 |
1717
| roomName | room |

tests/integration/features/federation/join-leave.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ Feature: federation/join-leave
44
Given using server "REMOTE"
55
And user "participant2" exists
66
And the following "spreed" app config is set
7-
| federation_enabled | yes |
7+
| federation_enabled | true |
88
And using server "LOCAL"
99
And user "participant1" exists
1010
And the following "spreed" app config is set
11-
| federation_enabled | yes |
11+
| federation_enabled | true |
1212

1313
Scenario: join a group room
1414
Given user "participant1" creates room "room" (v4)

0 commit comments

Comments
 (0)