diff --git a/server/presenters/collection.ts b/server/presenters/collection.ts index 0b370301cb..6d2f95e689 100644 --- a/server/presenters/collection.ts +++ b/server/presenters/collection.ts @@ -59,6 +59,13 @@ export default async function presentCollection( if (!options.isPublic) { res.archivedBy = collection.archivedBy && presentUser(collection.archivedBy); + res.sourceMetadata = collection.sourceMetadata + ? { + externalId: collection.sourceMetadata.externalId, + externalName: collection.sourceMetadata.externalName, + createdByName: collection.sourceMetadata.createdByName, + } + : undefined; } return res; diff --git a/server/queues/processors/ImportsProcessor.ts b/server/queues/processors/ImportsProcessor.ts index 7d10285720..33a313752e 100644 --- a/server/queues/processors/ImportsProcessor.ts +++ b/server/queues/processors/ImportsProcessor.ts @@ -19,6 +19,7 @@ import { MentionType, ProsemirrorData, ProsemirrorDoc, + SourceMetadata, } from "@shared/types"; import { colorPalette } from "@shared/utils/collections"; import { CollectionValidation } from "@shared/validations"; @@ -357,6 +358,13 @@ export default abstract class ImportsProcessor< } ); + // Build sourceMetadata for the collection + const sourceMetadata: SourceMetadata = { + externalId: externalId, + externalName: output.title, + createdByName: output.author, + }; + const collection = Collection.build({ id: internalId, name: output.title, @@ -372,6 +380,7 @@ export default abstract class ImportsProcessor< index: collectionIdx, sort: Collection.DEFAULT_SORT, permission: collectionItem.permission, + sourceMetadata, createdAt: output.createdAt ?? now, updatedAt: output.updatedAt ?? now, });