diff --git a/server/api/shares.js b/server/api/shares.js index 15caf93b..35b9f345 100644 --- a/server/api/shares.js +++ b/server/api/shares.js @@ -64,6 +64,7 @@ router.post('shares.create', auth(), async ctx => { documentId, userId: user.id, teamId: user.teamId, + revokedAt: null, }, }); diff --git a/server/api/shares.test.js b/server/api/shares.test.js index c768f42a..fd65a08e 100644 --- a/server/api/shares.test.js +++ b/server/api/shares.test.js @@ -88,6 +88,24 @@ describe('#shares.create', async () => { expect(body.data.documentTitle).toBe(document.title); }); + it('should allow creating a share record if link previously revoked', async () => { + const { user, document } = await seed(); + const share = await buildShare({ + documentId: document.id, + teamId: user.teamId, + userId: user.id, + }); + await share.revoke(); + const res = await server.post('/api/shares.create', { + body: { token: user.getJwtToken(), documentId: document.id }, + }); + const body = await res.json(); + + expect(res.status).toEqual(200); + expect(body.data.id).not.toEqual(share.id); + expect(body.data.documentTitle).toBe(document.title); + }); + it('should return existing share link for document and user', async () => { const { user, document } = await seed(); const share = await buildShare({