fix: set per-user instead of globally

This commit is contained in:
2024-08-08 23:16:22 +02:00
parent ea9a60558f
commit 2d10b81650
2 changed files with 15 additions and 14 deletions

View File

@ -16,20 +16,21 @@ use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
class SettingsController extends Controller {
public function __construct($appName, IRequest $request, private AppSettings $appSettings) {
public function __construct($appName, IRequest $request, private AppSettings $appSettings, private $userId) {
parent::__construct($appName, $request);
}
#[NoAdminRequired]
#[NoCSRFRequired]
public function get(): JSONResponse {
return $this->makeJSONResponse(fn () => $this->appSettings->getAll());
return $this->makeJSONResponse(fn () => $this->appSettings->getAll($this->userId));
}
#[NoAdminRequired]
public function set(string $folderVariant, string $buttonVariant): JSONResponse {
$this->appSettings->set($folderVariant, $buttonVariant);
return $this->makeJSONResponse(fn () => $this->appSettings->getAll());
$this->appSettings->set($this->userId, $folderVariant, $buttonVariant);
return $this->makeJSONResponse(fn () => $this->appSettings->getAll($this->userId));
}
protected function makeJSONResponse(Closure $closure): JSONResponse {