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
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import { NotificationEventType } from "@shared/types";
|
|
import { Notification } from "@server/models";
|
|
import { buildCollection, buildUser } from "@server/test/factories";
|
|
import CollectionAddOwnerNotificationsTask from "./CollectionAddOwnerNotificationsTask";
|
|
|
|
const ip = "127.0.0.1";
|
|
|
|
describe("CollectionAddOwnerNotificationsTask", () => {
|
|
const perform = (userId: string, collectionId: string, teamId: string) =>
|
|
new CollectionAddOwnerNotificationsTask().perform({
|
|
name: "collections.add_owner",
|
|
userId,
|
|
modelId: collectionId,
|
|
collectionId,
|
|
teamId,
|
|
actorId: userId,
|
|
ip,
|
|
});
|
|
|
|
it("should notify a user made an owner of a collection", async () => {
|
|
const owner = await buildUser();
|
|
const collection = await buildCollection({
|
|
teamId: owner.teamId,
|
|
ownerIds: [owner.id],
|
|
});
|
|
|
|
await perform(owner.id, collection.id, owner.teamId);
|
|
|
|
const notifications = await Notification.findAll({
|
|
where: { userId: owner.id },
|
|
});
|
|
expect(notifications.map((notification) => notification.event)).toEqual([
|
|
NotificationEventType.AddOwnerToCollection,
|
|
]);
|
|
expect(notifications[0].collectionId).toEqual(collection.id);
|
|
});
|
|
|
|
it("should not notify a user that is no longer an owner", async () => {
|
|
const user = await buildUser();
|
|
const collection = await buildCollection({ teamId: user.teamId });
|
|
|
|
await perform(user.id, collection.id, user.teamId);
|
|
|
|
expect(await Notification.count({ where: { userId: user.id } })).toBe(0);
|
|
});
|
|
});
|