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
59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
import { SubscriptionType } from "@shared/types";
|
|
import { Subscription } from "@server/models";
|
|
import { buildCollection, buildUser } from "@server/test/factories";
|
|
import CollectionSubscriptionAddOwnerTask from "./CollectionSubscriptionAddOwnerTask";
|
|
|
|
const ip = "127.0.0.1";
|
|
|
|
describe("CollectionSubscriptionAddOwnerTask", () => {
|
|
const perform = (userId: string, collectionId: string, teamId: string) =>
|
|
new CollectionSubscriptionAddOwnerTask().perform({
|
|
name: "collections.add_owner",
|
|
userId,
|
|
modelId: collectionId,
|
|
collectionId,
|
|
teamId,
|
|
actorId: userId,
|
|
ip,
|
|
});
|
|
|
|
it("should subscribe an owner to the 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 subscriptions = await Subscription.findAll({
|
|
where: { userId: owner.id, collectionId: collection.id },
|
|
});
|
|
expect(subscriptions.map((subscription) => subscription.event)).toEqual([
|
|
SubscriptionType.Document,
|
|
]);
|
|
});
|
|
|
|
it("should respect a previous unsubscribe", async () => {
|
|
const owner = await buildUser();
|
|
const collection = await buildCollection({
|
|
teamId: owner.teamId,
|
|
ownerIds: [owner.id],
|
|
});
|
|
const subscription = await Subscription.create({
|
|
userId: owner.id,
|
|
collectionId: collection.id,
|
|
event: SubscriptionType.Document,
|
|
});
|
|
await subscription.destroy();
|
|
|
|
await perform(owner.id, collection.id, owner.teamId);
|
|
|
|
expect(
|
|
await Subscription.count({
|
|
where: { userId: owner.id, collectionId: collection.id },
|
|
})
|
|
).toBe(0);
|
|
});
|
|
});
|