| 238 | } |
| 239 | |
| 240 | private async editFolder(id: string, req: FolderExport) { |
| 241 | const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId)); |
| 242 | const folder = await this.folderService.getFromState(id, activeUserId); |
| 243 | if (folder == null) { |
| 244 | return Response.notFound(); |
| 245 | } |
| 246 | |
| 247 | const userKey = await firstValueFrom(this.keyService.userKey$(activeUserId)); |
| 248 | let folderView = await folder.decrypt(userKey); |
| 249 | folderView = FolderExport.toView(req, folderView); |
| 250 | |
| 251 | const encFolder = await this.folderService.encrypt(folderView, userKey); |
| 252 | try { |
| 253 | const folder = await this.folderApiService.save(encFolder, activeUserId); |
| 254 | const updatedFolder = new Folder(folder); |
| 255 | const decFolder = await updatedFolder.decrypt(userKey); |
| 256 | const useSharedFoldersTerm = await this.configService.getFeatureFlag( |
| 257 | FeatureFlag.VFO1Foundation, |
| 258 | ); |
| 259 | const res = new FolderResponse(decFolder, useSharedFoldersTerm); |
| 260 | return Response.success(res); |
| 261 | } catch (e) { |
| 262 | return Response.error(e); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | private async editOrganizationCollection( |
| 267 | id: string, |