Skip to content

Commit 0d4a4d7

Browse files
committed
fix(esigner-api): sync file name and displayName from webhook so renames in File Manager appear in eSigner
- Update existing file from repo so entity is mutable - Apply name, displayName, description, mimeType, size, md5Hash only when present in payload so renames and partial syncs propagate correctly
1 parent 76eb738 commit 0d4a4d7

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

platforms/esigner-api/src/controllers/WebhookController.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,21 +276,29 @@ export class WebhookController {
276276
}
277277

278278
if (localId) {
279-
// Update existing file
280-
const file = await this.fileService.getFileById(localId);
279+
// Update existing file – apply name/displayName so renames in File Manager sync to eSigner
280+
const file = await this.fileRepository.findOne({
281+
where: { id: localId },
282+
});
281283
if (!file) {
282284
console.error("File not found for localId:", localId);
283285
return res.status(500).send();
284286
}
285287

286-
file.name = local.data.name as string;
287-
file.displayName = local.data.displayName as string | null;
288-
file.description = local.data.description as string | null;
289-
file.mimeType = local.data.mimeType as string;
290-
file.size = local.data.size as number;
291-
file.md5Hash = local.data.md5Hash as string;
288+
if (local.data.name !== undefined)
289+
file.name = local.data.name as string;
290+
if (local.data.displayName !== undefined)
291+
file.displayName = local.data.displayName as string | null;
292+
if (local.data.description !== undefined)
293+
file.description = local.data.description as string | null;
294+
if (local.data.mimeType !== undefined)
295+
file.mimeType = local.data.mimeType as string;
296+
if (local.data.size !== undefined)
297+
file.size = local.data.size as number;
298+
if (local.data.md5Hash !== undefined)
299+
file.md5Hash = local.data.md5Hash as string;
292300
file.ownerId = owner.id;
293-
301+
294302
// Decode base64 data if provided
295303
if (local.data.data && typeof local.data.data === "string") {
296304
file.data = Buffer.from(local.data.data, "base64");

0 commit comments

Comments
 (0)