Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/Controller/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\Attribute\UseSession;
use OCP\AppFramework\Http\DataResponse;
use OCP\IConfig;
use OCP\Config\IUserConfig;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IURLGenerator;
Expand Down Expand Up @@ -58,7 +58,7 @@ public function __construct(
protected IUserSession $userSession,
protected SessionService $sessionService,
private ValidateHelper $validateHelper,
private IConfig $config,
private IUserConfig $userConfig,
) {
parent::__construct(Application::APP_ID, $request);
}
Expand Down Expand Up @@ -419,7 +419,7 @@ public function setConfig(string $key): DataResponse {
$value = json_encode($value);
}

$this->config->setUserValue($user->getUID(), Application::APP_ID, $key, $value);
$this->userConfig->setValueString($user->getUID(), Application::APP_ID, $key, $value);

return new DataResponse([
'key' => $key,
Expand Down
12 changes: 6 additions & 6 deletions lib/Migration/Version12000Date20250517134200.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
use Closure;
use OCA\Libresign\AppInfo\Application;
use OCP\DB\ISchemaWrapper;
use OCP\IConfig;
use OCP\IAppConfig;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version12000Date20250517134200 extends SimpleMigrationStep {
public function __construct(
protected IConfig $config,
protected IAppConfig $appConfig,
) {
}

Expand All @@ -29,11 +29,11 @@ public function __construct(
*/
#[\Override]
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
$keys = $this->config->getAppKeys(Application::APP_ID);
$keys = $this->appConfig->getKeys(Application::APP_ID);
if (in_array('notify_unsigned_user', $keys)) {
$current = $this->config->getAppValue(Application::APP_ID, 'notify_unsigned_user');
$this->config->setAppValue('activity', 'notify_email_libresign_file_to_sign', $current ? '1' : '0');
$this->config->deleteAppValue(Application::APP_ID, 'notify_unsigned_user');
$current = $this->appConfig->getValueString(Application::APP_ID, 'notify_unsigned_user');
$this->appConfig->setValueString('activity', 'notify_email_libresign_file_to_sign', $current ? '1' : '0');
$this->appConfig->deleteKey(Application::APP_ID, 'notify_unsigned_user');
}
}
}
17 changes: 8 additions & 9 deletions lib/Service/AccountService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
use OCP\Accounts\IAccountManager;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Config\IUserConfig;
use OCP\Files\Config\IMountProviderCollection;
use OCP\Files\File;
use OCP\Files\IMimeTypeDetector;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\Http\Client\IClientService;
use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IURLGenerator;
Expand All @@ -61,8 +61,8 @@ public function __construct(
private SignFileService $signFileService,
private RequestSignatureService $requestSignatureService,
private CertificateEngineFactory $certificateEngineFactory,
private IConfig $config,
private IAppConfig $appConfig,
private IUserConfig $userConfig,
private IMountProviderCollection $mountProviderCollection,
private NewUserMailHelper $newUserMail,
private IdentifyMethodService $identifyMethodService,
Expand Down Expand Up @@ -160,7 +160,7 @@ public function createToSign(string $uuid, string $email, string $password, ?str

$this->updateIdentifyMethodToAccount($signRequest->getId(), $email, $newUser->getUID());

if ($this->config->getAppValue('core', 'newUser.sendEmail', 'yes') === 'yes') {
if ($this->appConfig->getValueString('core', 'newUser.sendEmail', 'yes') === 'yes') {
try {
$emailTemplate = $this->newUserMail->generateTemplate($newUser, false);
$this->newUserMail->sendMail($newUser, $emailTemplate);
Expand Down Expand Up @@ -262,16 +262,15 @@ private function getUserConfigByKey(string $key, ?IUser $user = null): string {
if (!$user) {
return '';
}

return $this->config->getUserValue($user->getUID(), Application::APP_ID, $key);
return $this->userConfig->getValueString($user->getUID(), Application::APP_ID, $key);
}

private function getUserConfigIdDocsFilters(?IUser $user = null): array {
if (!$user) {
return [];
}

$value = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'id_docs_filters', '');
$value = $this->userConfig->getValueString($user->getUID(), Application::APP_ID, 'id_docs_filters', '');
if (empty($value)) {
return [];
}
Expand All @@ -285,7 +284,7 @@ private function getUserConfigCrlFilters(?IUser $user = null): array {
return [];
}

$value = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'crl_filters', '');
$value = $this->userConfig->getValueString($user->getUID(), Application::APP_ID, 'crl_filters', '');
if (empty($value)) {
return [];
}
Expand All @@ -299,7 +298,7 @@ private function getUserConfigCrlSort(?IUser $user): array {
return ['sortBy' => 'revoked_at', 'sortOrder' => 'DESC'];
}

$value = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'crl_sort', '');
$value = $this->userConfig->getValueString($user->getUID(), Application::APP_ID, 'crl_sort', '');
if (empty($value)) {
return ['sortBy' => 'revoked_at', 'sortOrder' => 'DESC'];
}
Expand All @@ -313,7 +312,7 @@ private function getUserConfigIdDocsSort(?IUser $user): array {
return ['sortBy' => null, 'sortOrder' => null];
}

$value = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'id_docs_sort', '');
$value = $this->userConfig->getValueString($user->getUID(), Application::APP_ID, 'id_docs_sort', '');
if (empty($value)) {
return ['sortBy' => null, 'sortOrder' => null];
}
Expand Down
10 changes: 5 additions & 5 deletions tests/php/Unit/Service/AccountServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
use OCA\Settings\Mailer\NewUserMailHelper;
use OCP\Accounts\IAccountManager;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\Config\IUserConfig;
use OCP\Files\Config\IMountProviderCollection;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IMimeTypeDetector;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IURLGenerator;
Expand All @@ -63,8 +63,8 @@ final class AccountServiceTest extends \OCA\Libresign\Tests\Unit\TestCase {
private FileTypeMapper&MockObject $fileTypeMapper;
private SignFileService&MockObject $signFile;
private CertificateEngineFactory&MockObject $certificateEngineFactory;
private IConfig&MockObject $config;
private IAppConfig&MockObject $appConfig;
private IUserConfig&MockObject $userConfig;
private IMountProviderCollection&MockObject $mountProviderCollection;
private NewUserMailHelper&MockObject $newUserMail;
private IdentifyMethodService&MockObject $identifyMethodService;
Expand Down Expand Up @@ -98,8 +98,8 @@ public function setUp(): void {
$this->signFile = $this->createMock(SignFileService::class);
$this->requestSignatureService = $this->createMock(RequestSignatureService::class);
$this->certificateEngineFactory = $this->createMock(CertificateEngineFactory::class);
$this->config = $this->createMock(IConfig::class);
$this->appConfig = $this->createMock(IAppConfig::class);
$this->userConfig = $this->createMock(IUserConfig::class);
$this->mountProviderCollection = $this->createMock(IMountProviderCollection::class);
$this->newUserMail = $this->createMock(NewUserMailHelper::class);
$this->identifyMethodService = $this->createMock(IdentifyMethodService::class);
Expand Down Expand Up @@ -130,8 +130,8 @@ private function getService(): AccountService {
$this->signFile,
$this->requestSignatureService,
$this->certificateEngineFactory,
$this->config,
$this->appConfig,
$this->userConfig,
$this->mountProviderCollection,
$this->newUserMail,
$this->identifyMethodService,
Expand Down Expand Up @@ -218,7 +218,7 @@ public function testCreateToSignWithErrorInSendingEmail():void {
$userToSign->method('getUID')->willReturn('username');
$this->userManager->method('createUser')->willReturn($userToSign);
$this->identifyMethodService->method('getIdentifyMethodsFromSignRequestId')->willReturn([]);
$this->config->method('getAppValue')->willReturn('yes');
$this->appConfig->method('getValueString')->willReturn('yes');
$template = $this->createMock(\OCP\Mail\IEMailTemplate::class);
$this->newUserMail->method('generateTemplate')->willReturn($template);
$this->newUserMail->method('sendMail')->willReturnCallback(function ():void {
Expand Down
Loading