Skip to content

Commit 0565755

Browse files
Merge pull request #1029 from nextcloud/feat/public-capabilities
2 parents 921bbe5 + c953253 commit 0565755

File tree

5 files changed

+120
-0
lines changed

5 files changed

+120
-0
lines changed

lib/AppInfo/Application.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use OCA\Registration\Events\PassedFormEvent;
1313
use OCA\Registration\Events\ShowFormEvent;
1414
use OCA\Registration\Events\ValidateFormEvent;
15+
use OCA\TermsOfService\PublicCapabilities;
1516
use OCA\TermsOfService\Checker;
1617
use OCA\TermsOfService\Filesystem\StorageWrapper;
1718
use OCA\TermsOfService\Listener\RegistrationIntegration;
@@ -51,6 +52,7 @@ public function register(IRegistrationContext $context): void {
5152
$context->registerEventListener(ShowFormEvent::class, RegistrationIntegration::class);
5253
$context->registerEventListener(ValidateFormEvent::class, RegistrationIntegration::class);
5354
$context->registerEventListener(PassedFormEvent::class, RegistrationIntegration::class);
55+
$context->registerCapability(PublicCapabilities::class);
5456
}
5557

5658
public function boot(IBootContext $context): void {

lib/PublicCapabilities.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OCA\TermsOfService;
11+
12+
use OCA\TermsOfService\AppInfo\Application;
13+
use OCP\Capabilities\IPublicCapability;
14+
use OCP\IConfig;
15+
16+
class PublicCapabilities implements IPublicCapability {
17+
public function __construct(
18+
private IConfig $config,
19+
) {
20+
}
21+
22+
/**
23+
* @return array{
24+
* terms_of_service: array{
25+
* enabled: true,
26+
* term_uuid: string,
27+
* },
28+
* }
29+
*/
30+
public function getCapabilities(): array {
31+
$termId = $this->config->getAppValue(Application::APPNAME, 'term_uuid');
32+
33+
return [
34+
'terms_of_service' => [
35+
'enabled' => true,
36+
'term_uuid' => $termId,
37+
],
38+
];
39+
}
40+
}

openapi-administration.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,32 @@
8888
}
8989
}
9090
},
91+
"PublicCapabilities": {
92+
"type": "object",
93+
"required": [
94+
"terms_of_service"
95+
],
96+
"properties": {
97+
"terms_of_service": {
98+
"type": "object",
99+
"required": [
100+
"enabled",
101+
"term_uuid"
102+
],
103+
"properties": {
104+
"enabled": {
105+
"type": "boolean",
106+
"enum": [
107+
true
108+
]
109+
},
110+
"term_uuid": {
111+
"type": "string"
112+
}
113+
}
114+
}
115+
}
116+
},
91117
"Terms": {
92118
"type": "object",
93119
"required": [

openapi-full.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,32 @@
8888
}
8989
}
9090
},
91+
"PublicCapabilities": {
92+
"type": "object",
93+
"required": [
94+
"terms_of_service"
95+
],
96+
"properties": {
97+
"terms_of_service": {
98+
"type": "object",
99+
"required": [
100+
"enabled",
101+
"term_uuid"
102+
],
103+
"properties": {
104+
"enabled": {
105+
"type": "boolean",
106+
"enum": [
107+
true
108+
]
109+
},
110+
"term_uuid": {
111+
"type": "string"
112+
}
113+
}
114+
}
115+
}
116+
},
91117
"Terms": {
92118
"type": "object",
93119
"required": [

openapi.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,32 @@
4444
}
4545
}
4646
},
47+
"PublicCapabilities": {
48+
"type": "object",
49+
"required": [
50+
"terms_of_service"
51+
],
52+
"properties": {
53+
"terms_of_service": {
54+
"type": "object",
55+
"required": [
56+
"enabled",
57+
"term_uuid"
58+
],
59+
"properties": {
60+
"enabled": {
61+
"type": "boolean",
62+
"enum": [
63+
true
64+
]
65+
},
66+
"term_uuid": {
67+
"type": "string"
68+
}
69+
}
70+
}
71+
}
72+
},
4773
"Terms": {
4874
"type": "object",
4975
"required": [

0 commit comments

Comments
 (0)