mirror of
https://github.com/outline/outline.git
synced 2026-11-25 23:24:06 +03:00
- Access requests are routed to owners that can manage the document before falling back to document, collection and workspace admins - Owners are subscribed to a document when they are added, respecting a previous unsubscribe - Owners that can edit a document can also manage its access, owners and archive it; ownership never grants access on its own - Owners are shown in the document byline, list items and search results, and document hover previews Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MJXFdSZ39ZGPf31jyGcYz
30 lines
885 B
TypeScript
30 lines
885 B
TypeScript
import { subscribeUserToDocument } from "@server/commands/subscriptionCreator";
|
|
import { Document, User } from "@server/models";
|
|
import { can } from "@server/policies";
|
|
import type { DocumentOwnerEvent } from "@server/types";
|
|
import { BaseTask } from "./base/BaseTask";
|
|
|
|
/**
|
|
* Subscribes a user to a document when they are made an owner of it.
|
|
*/
|
|
export default class DocumentSubscriptionAddOwnerTask extends BaseTask<DocumentOwnerEvent> {
|
|
public async perform(event: DocumentOwnerEvent) {
|
|
const user = await User.findByPk(event.userId);
|
|
if (!user || user.isSuspended) {
|
|
return;
|
|
}
|
|
|
|
const document = await Document.findByPk(event.documentId, {
|
|
userId: user.id,
|
|
});
|
|
if (
|
|
!document?.ownerIds?.includes(user.id) ||
|
|
!can(user, "read", document)
|
|
) {
|
|
return;
|
|
}
|
|
|
|
await subscribeUserToDocument(user, document, event);
|
|
}
|
|
}
|