fix: Improved handling of delete events from collection and document sockets (#1517)

* handle delete events fron collection and document sockets

* handle collection deletes to documents

* rework semantics to always reload after a delete

Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
Nan Yu
2020-09-07 19:05:10 -07:00
committed by GitHub
parent ceeac9b982
commit e7ab2939d4
4 changed files with 54 additions and 16 deletions

View File

@@ -407,11 +407,15 @@ async function loadDocument({ id, shareId, user }) {
authorize(user, "read", document);
}
} else {
document = await Document.findByPk(
id,
user ? { userId: user.id } : undefined
);
authorize(user, "read", document);
document = await Document.findByPk(id, {
userId: user ? user.id : undefined,
paranoid: false,
});
if (document.deletedAt) {
authorize(user, "restore", document);
} else {
authorize(user, "read", document);
}
}
return document;