Filter private info from public shares
This commit is contained in:
@@ -161,7 +161,9 @@ router.post('documents.info', auth({ required: false }), async ctx => {
|
||||
const { id, shareId } = ctx.body;
|
||||
ctx.assertPresent(id || shareId, 'id or shareId is required');
|
||||
|
||||
const isPublic = !!shareId;
|
||||
let document;
|
||||
|
||||
if (shareId) {
|
||||
const share = await Share.findById(shareId, {
|
||||
include: [
|
||||
@@ -172,8 +174,6 @@ router.post('documents.info', auth({ required: false }), async ctx => {
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// TODO: REMOVE COLLECTION AND COLLABORATOR INFO
|
||||
document = share.document;
|
||||
} else {
|
||||
document = await Document.findById(id);
|
||||
@@ -181,7 +181,7 @@ router.post('documents.info', auth({ required: false }), async ctx => {
|
||||
}
|
||||
|
||||
ctx.body = {
|
||||
data: await presentDocument(ctx, document),
|
||||
data: await presentDocument(ctx, document, { isPublic }),
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -52,14 +52,14 @@ router.post('shares.create', auth(), async ctx => {
|
||||
const document = await Document.findById(id);
|
||||
authorize(user, 'share', document);
|
||||
|
||||
const [share, created] = await Share.findOrCreate({
|
||||
const [share] = await Share.findOrCreate({
|
||||
where: {
|
||||
documentId: document.id,
|
||||
userId: user.id,
|
||||
teamId: user.teamId,
|
||||
},
|
||||
});
|
||||
console.log('created', created);
|
||||
|
||||
share.user = user;
|
||||
share.document = document;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user