fix: async error in backlinks service when dealing with a deleted document

This commit is contained in:
Tom Moor 2020-09-03 22:44:42 -07:00
parent b93a397ab3
commit dd7436f78c

View File

@ -55,7 +55,9 @@ export default class Backlinks {
await Promise.all( await Promise.all(
addedLinkIds.map(async (linkId) => { addedLinkIds.map(async (linkId) => {
const linkedDocument = await Document.findByPk(linkId); const linkedDocument = await Document.findByPk(linkId);
if (linkedDocument.id === event.documentId) return; if (!linkedDocument || linkedDocument.id === event.documentId) {
return;
}
await Backlink.findOrCreate({ await Backlink.findOrCreate({
where: { where: {