mirror of
https://github.com/outline/outline.git
synced 2026-12-05 10:45:07 +03:00
fix: Align empty trash scope with trash listing (#14769)
This commit is contained in:
1 parent
168dc32111
commit
ff9735f573
2 files changed
+43
-8
No files matched your search
@@ -40,6 +40,7 @@ import { DocumentHelper } from "@server/models/helpers/DocumentHelper";
|
||||
import HTMLHelper from "@server/models/helpers/HTMLHelper";
|
||||
import { ProsemirrorHelper } from "@server/models/helpers/ProsemirrorHelper";
|
||||
import DocumentImportTask from "@server/queues/tasks/DocumentImportTask";
|
||||
import EmptyTrashTask from "@server/queues/tasks/EmptyTrashTask";
|
||||
import { sequelize } from "@server/storage/database";
|
||||
import FileStorage from "@server/storage/files";
|
||||
import {
|
||||
@@ -10143,6 +10144,30 @@ describe("#documents.empty_trash", () => {
|
||||
expect(res.status).toEqual(403);
|
||||
expect(body).toMatchSnapshot();
|
||||
});
|
||||
it("should not delete trashed drafts of other collection members", async () => {
|
||||
const admin = await buildAdmin();
|
||||
const other = await buildUser({ teamId: admin.teamId });
|
||||
const collection = await buildCollection({ teamId: admin.teamId });
|
||||
const otherDraft = await buildDraftDocument({
|
||||
userId: other.id,
|
||||
teamId: admin.teamId,
|
||||
collectionId: collection.id,
|
||||
});
|
||||
const otherDocument = await buildDocument({
|
||||
userId: other.id,
|
||||
teamId: admin.teamId,
|
||||
collectionId: collection.id,
|
||||
});
|
||||
await withContext(other, (ctx) => otherDraft.destroyWithCtx(ctx));
|
||||
await withContext(other, (ctx) => otherDocument.destroyWithCtx(ctx));
|
||||
const schedule = vi.spyOn(EmptyTrashTask.prototype, "schedule");
|
||||
|
||||
const res = await server.post("/api/documents.empty_trash", admin);
|
||||
expect(res.status).toEqual(200);
|
||||
expect(schedule).toHaveBeenCalledWith({
|
||||
documentIds: [otherDocument.id],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("#documents.documents", () => {
|
||||
|
||||
@@ -2356,17 +2356,27 @@ router.post(
|
||||
deletedAt: {
|
||||
[Op.ne]: null,
|
||||
},
|
||||
[Op.or]: [
|
||||
[Op.and]: [
|
||||
{
|
||||
collectionId: {
|
||||
[Op.in]: collectionIds,
|
||||
},
|
||||
[Op.or]: [
|
||||
{
|
||||
collectionId: {
|
||||
[Op.in]: collectionIds,
|
||||
},
|
||||
},
|
||||
{
|
||||
createdById: user.id,
|
||||
collectionId: {
|
||||
[Op.is]: null,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
createdById: user.id,
|
||||
collectionId: {
|
||||
[Op.is]: null,
|
||||
},
|
||||
[Op.or]: [
|
||||
{ publishedAt: { [Op.ne]: null } },
|
||||
...(await draftVisibilityClauses(user)),
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user