feat: allow global settings as fallback when user has not defined any
This commit is contained in:
@ -14,6 +14,7 @@ use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
||||
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
||||
use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting;
|
||||
|
||||
class SettingsController extends Controller {
|
||||
|
||||
@ -33,6 +34,17 @@ class SettingsController extends Controller {
|
||||
return $this->makeJSONResponse(fn () => $this->appSettings->getAll($this->userId));
|
||||
}
|
||||
|
||||
#[AuthorizedAdminSetting]
|
||||
public function setGlobal(string $folderVariant, string $buttonVariant): JSONResponse {
|
||||
$this->appSettings->setGlobal($folderVariant, $buttonVariant);
|
||||
return $this->makeJSONResponse(fn () => $this->appSettings->getGlobal());
|
||||
}
|
||||
|
||||
#[NoCSRFRequired]
|
||||
public function getGlobal(): JSONResponse {
|
||||
return $this->makeJSONResponse(fn () => $this->appSettings->getGlobal());
|
||||
}
|
||||
|
||||
protected function makeJSONResponse(Closure $closure): JSONResponse {
|
||||
try {
|
||||
return new JSONResponse($closure(), HTTP::STATUS_OK);
|
||||
|
Reference in New Issue
Block a user