Skip to content

Commit

Permalink
Merge pull request #1029 from nextcloud/feat/public-capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
provokateurin authored Dec 23, 2024
2 parents 921bbe5 + c953253 commit 0565755
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OCA\Registration\Events\PassedFormEvent;
use OCA\Registration\Events\ShowFormEvent;
use OCA\Registration\Events\ValidateFormEvent;
use OCA\TermsOfService\PublicCapabilities;
use OCA\TermsOfService\Checker;
use OCA\TermsOfService\Filesystem\StorageWrapper;
use OCA\TermsOfService\Listener\RegistrationIntegration;
Expand Down Expand Up @@ -51,6 +52,7 @@ public function register(IRegistrationContext $context): void {
$context->registerEventListener(ShowFormEvent::class, RegistrationIntegration::class);
$context->registerEventListener(ValidateFormEvent::class, RegistrationIntegration::class);
$context->registerEventListener(PassedFormEvent::class, RegistrationIntegration::class);
$context->registerCapability(PublicCapabilities::class);
}

public function boot(IBootContext $context): void {
Expand Down
40 changes: 40 additions & 0 deletions lib/PublicCapabilities.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\TermsOfService;

use OCA\TermsOfService\AppInfo\Application;
use OCP\Capabilities\IPublicCapability;
use OCP\IConfig;

class PublicCapabilities implements IPublicCapability {
public function __construct(
private IConfig $config,
) {
}

/**
* @return array{
* terms_of_service: array{
* enabled: true,
* term_uuid: string,
* },
* }
*/
public function getCapabilities(): array {
$termId = $this->config->getAppValue(Application::APPNAME, 'term_uuid');

return [
'terms_of_service' => [
'enabled' => true,
'term_uuid' => $termId,
],
];
}
}
26 changes: 26 additions & 0 deletions openapi-administration.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,32 @@
}
}
},
"PublicCapabilities": {
"type": "object",
"required": [
"terms_of_service"
],
"properties": {
"terms_of_service": {
"type": "object",
"required": [
"enabled",
"term_uuid"
],
"properties": {
"enabled": {
"type": "boolean",
"enum": [
true
]
},
"term_uuid": {
"type": "string"
}
}
}
}
},
"Terms": {
"type": "object",
"required": [
Expand Down
26 changes: 26 additions & 0 deletions openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,32 @@
}
}
},
"PublicCapabilities": {
"type": "object",
"required": [
"terms_of_service"
],
"properties": {
"terms_of_service": {
"type": "object",
"required": [
"enabled",
"term_uuid"
],
"properties": {
"enabled": {
"type": "boolean",
"enum": [
true
]
},
"term_uuid": {
"type": "string"
}
}
}
}
},
"Terms": {
"type": "object",
"required": [
Expand Down
26 changes: 26 additions & 0 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,32 @@
}
}
},
"PublicCapabilities": {
"type": "object",
"required": [
"terms_of_service"
],
"properties": {
"terms_of_service": {
"type": "object",
"required": [
"enabled",
"term_uuid"
],
"properties": {
"enabled": {
"type": "boolean",
"enum": [
true
]
},
"term_uuid": {
"type": "string"
}
}
}
}
},
"Terms": {
"type": "object",
"required": [
Expand Down

0 comments on commit 0565755

Please sign in to comment.