mirror of
https://github.com/outline/outline.git
synced 2026-11-25 23:24:06 +03:00
- Collections can have owners, who also own every document in the collection, shown first in document bylines - Owner is a role in the collection share panel and invite picker for individual users, adding an owner gives them the manage permission - Lowering an owner's permission or removing their access removes the ownership - ownerIds on collections.create, collections.update and the MCP collection tools - The document owner filter includes documents in owned collections - Access requests go to document and collection owners together - Collection owners are subscribed to the collection and notified when they are added - Deleted users are removed from collection owners - Renames the personal collection policy helper to isPersonalCollectionOwner
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
import { CollectionPermission, NotificationEventType } from "@shared/types";
|
|
import { Notification, UserMembership } from "@server/models";
|
|
import { buildCollection, buildUser } from "@server/test/factories";
|
|
import CollectionAddUserNotificationsTask from "./CollectionAddUserNotificationsTask";
|
|
|
|
const ip = "127.0.0.1";
|
|
|
|
describe("CollectionAddUserNotificationsTask", () => {
|
|
const perform = async (ownerIds: (userId: string) => string[]) => {
|
|
const actor = await buildUser();
|
|
const user = await buildUser({ teamId: actor.teamId });
|
|
const collection = await buildCollection({
|
|
teamId: actor.teamId,
|
|
userId: actor.id,
|
|
ownerIds: ownerIds(user.id),
|
|
});
|
|
const membership = await UserMembership.create({
|
|
collectionId: collection.id,
|
|
userId: user.id,
|
|
createdById: actor.id,
|
|
permission: CollectionPermission.Admin,
|
|
});
|
|
|
|
await new CollectionAddUserNotificationsTask().perform({
|
|
name: "collections.add_user",
|
|
userId: user.id,
|
|
modelId: membership.id,
|
|
collectionId: collection.id,
|
|
teamId: actor.teamId,
|
|
actorId: actor.id,
|
|
ip,
|
|
});
|
|
|
|
return Notification.count({
|
|
where: {
|
|
userId: user.id,
|
|
event: NotificationEventType.AddUserToCollection,
|
|
},
|
|
});
|
|
};
|
|
|
|
it("should notify a user added to a collection", async () => {
|
|
expect(await perform(() => [])).toBe(1);
|
|
});
|
|
|
|
it("should not notify a user that is an owner of the collection", async () => {
|
|
expect(await perform((userId) => [userId])).toBe(0);
|
|
});
|
|
});
|