mirror of
https://github.com/outline/outline.git
synced 2026-11-21 13:34:02 +03:00
* createContext accepts object * handle subscriptions * use createContext * should've done this on the initial attempt...
32 lines
950 B
TypeScript
32 lines
950 B
TypeScript
import subscriptionCreator from "@server/commands/subscriptionCreator";
|
|
import { createContext } from "@server/context";
|
|
import { User } from "@server/models";
|
|
import { sequelize } from "@server/storage/database";
|
|
import { DocumentUserEvent, Event } from "@server/types";
|
|
import BaseProcessor from "./BaseProcessor";
|
|
|
|
export default class DocumentUserAddedProcessor extends BaseProcessor {
|
|
static applicableEvents: Event["name"][] = ["documents.add_user"];
|
|
|
|
async perform(event: DocumentUserEvent) {
|
|
const user = await User.findByPk(event.userId);
|
|
if (!user) {
|
|
return;
|
|
}
|
|
|
|
await sequelize.transaction(async (transaction) => {
|
|
await subscriptionCreator({
|
|
ctx: createContext({
|
|
user,
|
|
authType: event.authType,
|
|
ip: event.ip,
|
|
transaction,
|
|
}),
|
|
documentId: event.documentId,
|
|
event: "documents.update",
|
|
resubscribe: false,
|
|
});
|
|
});
|
|
}
|
|
}
|