Skip to content

Commit 5d96dbf

Browse files
ArtificialOwlbackportbot[bot]
authored andcommitted
lexicon
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
1 parent 995ac1d commit 5d96dbf

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/ConfigLexicon.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@
2121
*/
2222
class ConfigLexicon implements ILexicon {
2323
public const USER_SINGLE_ID = 'userSingleId';
24+
public const FEDERATED_TEAMS_ENABLED = 'federated_teams_enabled';
25+
public const FEDERATED_TEAMS_FRONTAL = 'federated_teams_frontal';
2426

2527
public function getStrictness(): Strictness {
2628
return Strictness::IGNORE;
2729
}
2830

2931
public function getAppConfigs(): array {
3032
return [
33+
new Entry(key: self::FEDERATED_TEAMS_ENABLED, type: ValueType::BOOL, defaultRaw: false, definition: 'disable/enable Federated Teams', lazy: true),
34+
new Entry(key: self::FEDERATED_TEAMS_FRONTAL, type: ValueType::STRING, defaultRaw: '', definition: 'domain name used to auth public request', lazy: true),
3135
];
3236
}
3337

lib/Controller/SettingsController.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace OCA\Circles\Controller;
1111

12+
use OCA\Circles\ConfigLexicon;
1213
use OCA\Circles\Service\ConfigService;
1314
use OCP\AppFramework\Http;
1415
use OCP\AppFramework\Http\DataResponse;
@@ -26,16 +27,16 @@ public function __construct(
2627
}
2728

2829
public function setValue(string $key, string $value): DataResponse {
29-
if ($key === 'frontal_cloud') {
30+
if ($key === ConfigLexicon::FEDERATED_TEAMS_FRONTAL) {
3031
if ($this->setFrontalValue($value)) {
3132
return $this->getValues();
3233
}
3334

3435
return new DataResponse(['data' => ['message' => 'wrongly formated value']], Http::STATUS_BAD_REQUEST);
3536
}
3637

37-
if ($key === 'federated_teams_enabled') {
38-
$this->appConfig->setAppValueBool('federated_teams_enabled', $value === 'yes');
38+
if ($key === ConfigLexicon::FEDERATED_TEAMS_ENABLED) {
39+
$this->appConfig->setAppValueBool(ConfigLexicon::FEDERATED_TEAMS_ENABLED, $value === 'yes');
3940
return $this->getValues();
4041
}
4142

@@ -44,8 +45,8 @@ public function setValue(string $key, string $value): DataResponse {
4445

4546
public function getValues(): DataResponse {
4647
return new DataResponse([
47-
'frontal_cloud' => $this->getFrontalValue() ?? '',
48-
'federated_teams_enabled' => $this->appConfig->getAppValueBool('federated_teams_enabled'),
48+
ConfigLexicon::FEDERATED_TEAMS_FRONTAL => $this->getFrontalValue() ?? '',
49+
ConfigLexicon::FEDERATED_TEAMS_ENABLED => $this->appConfig->getAppValueBool(ConfigLexicon::FEDERATED_TEAMS_ENABLED),
4950
]);
5051
}
5152

@@ -55,6 +56,7 @@ private function setFrontalValue(string $url): bool {
5556
return false;
5657
}
5758

59+
$this->appConfig->setAppValueString(ConfigLexicon::FEDERATED_TEAMS_FRONTAL, $url);
5860
$this->appConfig->setAppValueString(ConfigService::FRONTAL_CLOUD_SCHEME, $scheme);
5961
$this->appConfig->setAppValueString(ConfigService::FRONTAL_CLOUD_ID, $cloudId);
6062
$this->appConfig->setAppValueString(ConfigService::FRONTAL_CLOUD_PATH, $path);
@@ -63,6 +65,10 @@ private function setFrontalValue(string $url): bool {
6365
}
6466

6567
private function getFrontalValue(): ?string {
68+
if ($this->appConfig->hasAppKey(ConfigLexicon::FEDERATED_TEAMS_FRONTAL)) {
69+
return $this->appConfig->getAppValueString(ConfigLExicon::FEDERATED_TEAMS_FRONTAL);
70+
}
71+
6672
if (!$this->appConfig->hasAppKey(ConfigService::FRONTAL_CLOUD_SCHEME)
6773
|| !$this->appConfig->hasAppKey(ConfigService::FRONTAL_CLOUD_ID)
6874
|| !$this->appConfig->hasAppKey(ConfigService::FRONTAL_CLOUD_PATH)) {

0 commit comments

Comments
 (0)