mirror of
https://github.com/outline/outline.git
synced 2026-11-28 16:19:46 +03:00
refactor
This commit is contained in:
11 files changed
+96
-93
No files matched your search
@@ -372,16 +372,6 @@ class Collection extends ParanoidModel<
|
||||
return `/collection/${slugifiedName}-${urlId}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key used to store the collaborators of a collection in Redis.
|
||||
*
|
||||
* @param collectionId The ID of the collection.
|
||||
* @returns Redis key for collaborators.
|
||||
*/
|
||||
static getCollaboratorKey(collectionId: string) {
|
||||
return `collaborators:${collectionId}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this collection is considered active or not. A collection is active if
|
||||
* it has not been archived or deleted.
|
||||
@@ -461,21 +451,11 @@ class Collection extends ParanoidModel<
|
||||
|
||||
@AfterUpdate
|
||||
static notifyCollaborationServer(model: Collection, ctx: HookContext) {
|
||||
if (model.changed("state") && ctx.auth?.user?.id) {
|
||||
const actorId = ctx.auth.user.id;
|
||||
const notify = async () => {
|
||||
await APIUpdateExtension.notifyUpdate(
|
||||
toMultiplayerName(MultiplayerEntityType.Collection, model.id),
|
||||
actorId
|
||||
);
|
||||
};
|
||||
|
||||
if (ctx.transaction) {
|
||||
const transaction = ctx.transaction.parent || ctx.transaction;
|
||||
transaction.afterCommit(notify);
|
||||
} else {
|
||||
void notify();
|
||||
}
|
||||
if (model.changed("state")) {
|
||||
APIUpdateExtension.notifyUpdateAfterCommit(
|
||||
toMultiplayerName(MultiplayerEntityType.Collection, model.id),
|
||||
ctx
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -422,15 +422,6 @@ class Document extends ArchivableModel<
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key used to store the collaborators of a document in Redis.
|
||||
* @param documentId The ID of the document.
|
||||
* @returns Redis key for collaborators
|
||||
*/
|
||||
static getCollaboratorKey(documentId: string) {
|
||||
return `collaborators:${documentId}`;
|
||||
}
|
||||
|
||||
static getPath({ title, urlId }: { title: string; urlId: string }) {
|
||||
if (!title.length) {
|
||||
return `/doc/untitled-${urlId}`;
|
||||
@@ -589,21 +580,11 @@ class Document extends ArchivableModel<
|
||||
|
||||
@AfterUpdate
|
||||
static notifyCollaborationServer(model: Document, ctx: HookContext) {
|
||||
if (model.changed("state") && ctx.auth?.user?.id) {
|
||||
const actorId = ctx.auth.user.id;
|
||||
const notify = async () => {
|
||||
await APIUpdateExtension.notifyUpdate(
|
||||
toMultiplayerName(MultiplayerEntityType.Document, model.id),
|
||||
actorId
|
||||
);
|
||||
};
|
||||
|
||||
if (ctx.transaction) {
|
||||
const transaction = ctx.transaction.parent || ctx.transaction;
|
||||
transaction.afterCommit(notify);
|
||||
} else {
|
||||
void notify();
|
||||
}
|
||||
if (model.changed("state")) {
|
||||
APIUpdateExtension.notifyUpdateAfterCommit(
|
||||
toMultiplayerName(MultiplayerEntityType.Document, model.id),
|
||||
ctx
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user