fix: Single share record per document (#1984)

This commit is contained in:
Tom Moor
2021-03-24 18:28:38 -07:00
committed by GitHub
parent 877c01f723
commit 46912f8ddb
3 changed files with 36 additions and 7 deletions

View File

@ -25,7 +25,7 @@ router.post("shares.info", auth(), async (ctx) => {
}
: {
documentId,
userId: user.id,
teamId: user.teamId,
revokedAt: { [Op.eq]: null },
},
});
@ -134,10 +134,12 @@ router.post("shares.create", auth(), async (ctx) => {
const [share, isCreated] = await Share.findOrCreate({
where: {
documentId,
userId: user.id,
teamId: user.teamId,
revokedAt: null,
},
defaults: {
userId: user.id,
},
});
if (isCreated) {