mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-26 18:58:21 +02:00
Server: Fixed deleting a note that has been shared
This commit is contained in:
parent
e156ee1b58
commit
489995daef
@ -84,4 +84,20 @@ describe('ShareModel', function() {
|
|||||||
expect(share1.id).toBe(share2.id);
|
expect(share1.id).toBe(share2.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should delete a note that has been shared', async function() {
|
||||||
|
const { user: user1 } = await createUserAndSession(1);
|
||||||
|
|
||||||
|
await createItemTree(user1.id, '', {
|
||||||
|
'000000000000000000000000000000F1': {
|
||||||
|
'00000000000000000000000000000001': null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await models().share().shareNote(user1, '00000000000000000000000000000001');
|
||||||
|
const noteItem = await models().item().loadByJopId(user1.id, '00000000000000000000000000000001');
|
||||||
|
await models().item().delete(noteItem.id);
|
||||||
|
expect(await models().item().load(noteItem.id)).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Item, Share, ShareUser, ShareUserStatus, User, Uuid } from '../db';
|
import { Item, Share, ShareType, ShareUser, ShareUserStatus, User, Uuid } from '../db';
|
||||||
import { ErrorForbidden, ErrorNotFound } from '../utils/errors';
|
import { ErrorForbidden, ErrorNotFound } from '../utils/errors';
|
||||||
import BaseModel, { AclAction, DeleteOptions } from './BaseModel';
|
import BaseModel, { AclAction, DeleteOptions } from './BaseModel';
|
||||||
|
|
||||||
@ -123,23 +123,13 @@ export default class ShareUserModel extends BaseModel<ShareUser> {
|
|||||||
|
|
||||||
return this.save({ ...shareUser, status });
|
return this.save({ ...shareUser, status });
|
||||||
});
|
});
|
||||||
|
|
||||||
// const item = await this.models().item().load(share.item_id);
|
|
||||||
|
|
||||||
// return this.withTransaction<Item>(async () => {
|
|
||||||
// await this.save({ ...shareUser, status });
|
|
||||||
|
|
||||||
// if (status === ShareUserStatus.Accepted) {
|
|
||||||
// if (share.type === ShareType.JoplinRootFolder) {
|
|
||||||
// // await this.models().item().shareJoplinFolderAndContent(share.id, share.owner_id, userId, item.jop_id);
|
|
||||||
// } else if (share.type === ShareType.App) {
|
|
||||||
// await this.models().userItem().add(userId, share.item_id, share.id);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async deleteByShare(share: Share): Promise<void> {
|
public async deleteByShare(share: Share): Promise<void> {
|
||||||
|
// Notes that are shared by link do not have associated ShareUser items,
|
||||||
|
// so there's nothing to do.
|
||||||
|
if (share.type !== ShareType.JoplinRootFolder) return;
|
||||||
|
|
||||||
const shareUsers = await this.byShareId(share.id, null);
|
const shareUsers = await this.byShareId(share.id, null);
|
||||||
|
|
||||||
await this.withTransaction(async () => {
|
await this.withTransaction(async () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user