1212use OC \Authentication \Login \Chain ;
1313use OC \Authentication \Login \LoginData ;
1414use OCA \Libresign \AppInfo \Application ;
15- use OCA \Libresign \Db \AccountFileMapper ;
1615use OCA \Libresign \Exception \LibresignException ;
1716use OCA \Libresign \Handler \SignEngine \Pkcs12Handler ;
1817use OCA \Libresign \Helper \JSActions ;
1918use OCA \Libresign \Helper \ValidateHelper ;
2019use OCA \Libresign \ResponseDefinitions ;
21- use OCA \Libresign \Service \AccountFileService ;
2220use OCA \Libresign \Service \AccountService ;
2321use OCA \Libresign \Service \SessionService ;
2422use OCA \Libresign \Service \SignerElementsService ;
4038use Psr \Log \LoggerInterface ;
4139
4240/**
43- * @psalm-import-type LibresignAccountFile from ResponseDefinitions
4441 * @psalm-import-type LibresignCertificatePfxData from ResponseDefinitions
4542 * @psalm-import-type LibresignFile from ResponseDefinitions
4643 * @psalm-import-type LibresignPagination from ResponseDefinitions
@@ -52,8 +49,6 @@ public function __construct(
5249 protected IL10N $ l10n ,
5350 private IAccountManager $ accountManager ,
5451 private AccountService $ accountService ,
55- private AccountFileService $ accountFileService ,
56- private AccountFileMapper $ accountFileMapper ,
5752 protected SignFileService $ signFileService ,
5853 private SignerElementsService $ signerElementsService ,
5954 private Pkcs12Handler $ pkcs12Handler ,
@@ -187,73 +182,6 @@ public function signatureGenerate(
187182 }
188183 }
189184
190- /**
191- * Add files to account profile
192- *
193- * @param LibresignAccountFile[] $files The list of files to add to profile
194- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED, array{file: ?int, type: 'info'|'warning'|'danger', message: string}, array{}>
195- *
196- * 200: Certificate saved with success
197- * 401: No file provided or other problem with provided file
198- */
199- #[NoAdminRequired]
200- #[NoCSRFRequired]
201- #[ApiRoute(verb: 'POST ' , url: '/api/{apiVersion}/account/files ' , requirements: ['apiVersion ' => '(v1) ' ])]
202- public function addFiles (array $ files ): DataResponse {
203- try {
204- $ this ->accountService ->addFilesToAccount ($ files , $ this ->userSession ->getUser ());
205- return new DataResponse ([], Http::STATUS_OK );
206- } catch (\Exception $ exception ) {
207- $ exceptionData = json_decode ($ exception ->getMessage ());
208- if (isset ($ exceptionData ->file )) {
209- $ message = [
210- 'file ' => $ exceptionData ->file ,
211- 'type ' => $ exceptionData ->type ,
212- 'message ' => $ exceptionData ->message
213- ];
214- } else {
215- $ message = [
216- 'file ' => null ,
217- 'type ' => null ,
218- 'message ' => $ exception ->getMessage ()
219- ];
220- }
221- return new DataResponse (
222- $ message ,
223- Http::STATUS_UNAUTHORIZED
224- );
225- }
226- }
227-
228- /**
229- * Delete file from account
230- *
231- * @param int $nodeId the nodeId of file to be delete
232- *
233- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED, array{messages: string[]}, array{}>
234- *
235- * 200: File deleted with success
236- * 401: Failure to delete file from account
237- */
238- #[NoAdminRequired]
239- #[NoCSRFRequired]
240- #[ApiRoute(verb: 'DELETE ' , url: '/api/{apiVersion}/account/files ' , requirements: ['apiVersion ' => '(v1) ' ])]
241- public function deleteFile (int $ nodeId ): DataResponse {
242- try {
243- $ this ->accountService ->deleteFileFromAccount ($ nodeId , $ this ->userSession ->getUser ());
244- return new DataResponse ([], Http::STATUS_OK );
245- } catch (\Exception $ exception ) {
246- return new DataResponse (
247- [
248- 'messages ' => [
249- $ exception ->getMessage (),
250- ],
251- ],
252- Http::STATUS_UNAUTHORIZED ,
253- );
254- }
255- }
256-
257185 /**
258186 * Who am I
259187 *
@@ -293,64 +221,6 @@ public function me(): DataResponse {
293221 );
294222 }
295223
296- /**
297- * List account files of authenticated account
298- *
299- * @param array{approved?: 'yes'}|null $filter Filter params
300- * @param int|null $page the number of page to return
301- * @param int|null $length Total of elements to return
302- * @return DataResponse<Http::STATUS_OK, array{pagination: LibresignPagination, data: LibresignFile[]}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, array{message: string}, array{}>
303- *
304- * 200: Certificate saved with success
305- * 404: No file provided or other problem with provided file
306- */
307- #[NoAdminRequired]
308- #[NoCSRFRequired]
309- #[ApiRoute(verb: 'GET ' , url: '/api/{apiVersion}/account/files ' , requirements: ['apiVersion ' => '(v1) ' ])]
310- public function accountFileListToOwner (array $ filter = [], ?int $ page = null , ?int $ length = null ): DataResponse {
311- try {
312- $ filter ['userId ' ] = $ this ->userSession ->getUser ()->getUID ();
313- $ return = $ this ->accountFileService ->accountFileList ($ filter , $ page , $ length );
314- return new DataResponse ($ return , Http::STATUS_OK );
315- } catch (\Throwable $ th ) {
316- return new DataResponse (
317- [
318- 'message ' => $ th ->getMessage ()
319- ],
320- Http::STATUS_NOT_FOUND
321- );
322- }
323- }
324-
325- /**
326- * List account files that need to be approved
327- *
328- * @param array{approved?: 'yes'}|null $filter Filter params
329- * @param int|null $page the number of page to return
330- * @param int|null $length Total of elements to return
331- * @return DataResponse<Http::STATUS_OK, array{pagination: LibresignPagination, data: ?LibresignFile[]}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, array{message: string}, array{}>
332- *
333- * 200: OK
334- * 404: Account not found
335- */
336- #[NoAdminRequired]
337- #[NoCSRFRequired]
338- #[ApiRoute(verb: 'GET ' , url: '/api/{apiVersion}/account/files/approval/list ' , requirements: ['apiVersion ' => '(v1) ' ])]
339- public function accountFileListToApproval (array $ filter = [], ?int $ page = null , ?int $ length = null ): DataResponse {
340- try {
341- $ this ->validateHelper ->userCanApproveValidationDocuments ($ this ->userSession ->getUser ());
342- $ return = $ this ->accountFileService ->accountFileList ($ filter , $ page , $ length );
343- return new DataResponse ($ return , Http::STATUS_OK );
344- } catch (\Throwable $ th ) {
345- return new DataResponse (
346- [
347- 'message ' => $ th ->getMessage ()
348- ],
349- Http::STATUS_NOT_FOUND
350- );
351- }
352- }
353-
354224 /**
355225 * Update the account phone number
356226 *
0 commit comments