diff --git a/src/func/imports/approve-import.ts b/src/func/imports/approve-import.ts index fe9b4db6..ead659a4 100644 --- a/src/func/imports/approve-import.ts +++ b/src/func/imports/approve-import.ts @@ -48,16 +48,20 @@ export async function approveImport( incrementEditorEditCountById(orm, editorId, transacting); // Create a new revision record - const revisionPromise = new Revision({ + const revision = await new Revision({ authorId: editorId }).save(null, {transacting}); + const revisionId = revision.get('id'); + + if (annotationId) { + // Set revision of our annotation which is NULL for imports + await new orm.Annotation({id: annotationId}) + .save({lastRevisionId: revisionId}, {transacting}); + } const note = `Approved from automatically imported record of ${source}`; // Create a new note promise - const notePromise = revisionPromise - .then((revision) => createNote( - orm, note, editorId, revision, transacting - )); + const notePromise = createNote(orm, note, editorId, revision, transacting); // Get additional props const additionalProps = getAdditionalEntityProps(importEntity, entityType); @@ -70,9 +74,7 @@ export async function approveImport( , {} ); - const [revisionRecord] = await Promise.all([ - revisionPromise, notePromise, editorUpdatePromise - ]); + await Promise.all([notePromise, editorUpdatePromise]); const newEntity = await new Entity({type: entityType}) .save(null, {transacting}); @@ -83,7 +85,7 @@ export async function approveImport( bbid, disambiguationId, identifierSetId, - revisionId: revisionRecord && revisionRecord.get('id') + revisionId }, entitySets, additionalProps); const Model = getEntityModelByType(orm, entityType);