| 188 | } |
| 189 | |
| 190 | private async editFolder(id: string, req: FolderExport) { |
| 191 | const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId)); |
| 192 | const folder = await this.folderService.getFromState(id, activeUserId); |
| 193 | if (folder == null) { |
| 194 | return Response.notFound(); |
| 195 | } |
| 196 | |
| 197 | const userKey = await firstValueFrom(this.keyService.userKey$(activeUserId)); |
| 198 | let folderView = await folder.decrypt(userKey); |
| 199 | folderView = FolderExport.toView(req, folderView); |
| 200 | |
| 201 | const encFolder = await this.folderService.encrypt(folderView, userKey); |
| 202 | try { |
| 203 | const folder = await this.folderApiService.save(encFolder, activeUserId); |
| 204 | const updatedFolder = new Folder(folder); |
| 205 | const decFolder = await updatedFolder.decrypt(userKey); |
| 206 | const res = new FolderResponse(decFolder); |
| 207 | return Response.success(res); |
| 208 | } catch (e) { |
| 209 | return Response.error(e); |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | private async editOrganizationCollection( |
| 214 | id: string, |