Skip to content

Commit 1ad1039

Browse files
committed
fix(file-manager-api): preserve file folder when webhook payload has no folderId
- When updating existing file, set file.folderId only if local.data.folderId is present in the payload - Prevents eSigner webhooks (no folder concept) from overwriting folderId and moving deeply nested files to root when signed
1 parent bc73a72 commit 1ad1039

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

platforms/file-manager-api/src/controllers/WebhookController.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ export class WebhookController {
291291
}
292292

293293
if (localId) {
294-
// Update existing file
294+
// Update existing file – only set folderId when payload carries it (e.g. from File Manager).
295+
// When payload has no folderId (e.g. from eSigner), preserve existing folder so nested files don't move to root.
295296
const file = await this.fileRepository.findOne({
296297
where: { id: localId },
297298
});
@@ -307,8 +308,10 @@ export class WebhookController {
307308
file.size = local.data.size as number;
308309
file.md5Hash = local.data.md5Hash as string;
309310
file.ownerId = owner.id;
310-
file.folderId = folderId;
311-
311+
if (local.data.folderId !== undefined) {
312+
file.folderId = folderId;
313+
}
314+
312315
// Decode base64 data if provided
313316
if (local.data.data && typeof local.data.data === "string") {
314317
file.data = Buffer.from(local.data.data, "base64");

0 commit comments

Comments
 (0)