id -> documentId
This commit is contained in:
@ -43,8 +43,6 @@ class Document extends BaseModel {
|
|||||||
views: number;
|
views: number;
|
||||||
revision: number;
|
revision: number;
|
||||||
|
|
||||||
data: Object;
|
|
||||||
|
|
||||||
/* Computed */
|
/* Computed */
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
@ -104,7 +102,7 @@ class Document extends BaseModel {
|
|||||||
@action
|
@action
|
||||||
share = async () => {
|
share = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await client.post('/shares.create', { id: this.id });
|
const res = await client.post('/shares.create', { documentId: this.id });
|
||||||
invariant(res && res.data, 'Document API response should be available');
|
invariant(res && res.data, 'Document API response should be available');
|
||||||
|
|
||||||
this.shareUrl = res.data.url;
|
this.shareUrl = res.data.url;
|
||||||
@ -289,7 +287,6 @@ class Document extends BaseModel {
|
|||||||
data.emoji = emoji;
|
data.emoji = emoji;
|
||||||
}
|
}
|
||||||
if (dirty) this.hasPendingChanges = true;
|
if (dirty) this.hasPendingChanges = true;
|
||||||
this.data = data;
|
|
||||||
extendObservable(this, data);
|
extendObservable(this, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,16 +45,16 @@ router.post('shares.list', auth(), pagination(), async ctx => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.post('shares.create', auth(), async ctx => {
|
router.post('shares.create', auth(), async ctx => {
|
||||||
const { id } = ctx.body;
|
const { documentId } = ctx.body;
|
||||||
ctx.assertPresent(id, 'id is required');
|
ctx.assertPresent(documentId, 'documentId is required');
|
||||||
|
|
||||||
const user = ctx.state.user;
|
const user = ctx.state.user;
|
||||||
const document = await Document.findById(id);
|
const document = await Document.findById(documentId);
|
||||||
authorize(user, 'share', document);
|
authorize(user, 'share', document);
|
||||||
|
|
||||||
const [share] = await Share.findOrCreate({
|
const [share] = await Share.findOrCreate({
|
||||||
where: {
|
where: {
|
||||||
documentId: document.id,
|
documentId,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
teamId: user.teamId,
|
teamId: user.teamId,
|
||||||
},
|
},
|
||||||
|
@ -62,7 +62,7 @@ describe('#shares.create', async () => {
|
|||||||
it('should allow creating a share record for document', async () => {
|
it('should allow creating a share record for document', async () => {
|
||||||
const { user, document } = await seed();
|
const { user, document } = await seed();
|
||||||
const res = await server.post('/api/shares.create', {
|
const res = await server.post('/api/shares.create', {
|
||||||
body: { token: user.getJwtToken(), id: document.id },
|
body: { token: user.getJwtToken(), documentId: document.id },
|
||||||
});
|
});
|
||||||
const body = await res.json();
|
const body = await res.json();
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ describe('#shares.create', async () => {
|
|||||||
userId: user.id,
|
userId: user.id,
|
||||||
});
|
});
|
||||||
const res = await server.post('/api/shares.create', {
|
const res = await server.post('/api/shares.create', {
|
||||||
body: { token: user.getJwtToken(), id: document.id },
|
body: { token: user.getJwtToken(), documentId: document.id },
|
||||||
});
|
});
|
||||||
const body = await res.json();
|
const body = await res.json();
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ describe('#shares.create', async () => {
|
|||||||
it('should require authentication', async () => {
|
it('should require authentication', async () => {
|
||||||
const { document } = await seed();
|
const { document } = await seed();
|
||||||
const res = await server.post('/api/shares.create', {
|
const res = await server.post('/api/shares.create', {
|
||||||
body: { id: document.id },
|
body: { documentId: document.id },
|
||||||
});
|
});
|
||||||
const body = await res.json();
|
const body = await res.json();
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ describe('#shares.create', async () => {
|
|||||||
const { document } = await seed();
|
const { document } = await seed();
|
||||||
const user = await buildUser();
|
const user = await buildUser();
|
||||||
const res = await server.post('/api/shares.create', {
|
const res = await server.post('/api/shares.create', {
|
||||||
body: { token: user.getJwtToken(), id: document.id },
|
body: { token: user.getJwtToken(), documentId: document.id },
|
||||||
});
|
});
|
||||||
expect(res.status).toEqual(403);
|
expect(res.status).toEqual(403);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user