mirror of
https://github.com/outline/outline.git
synced 2026-11-23 06:11:04 +03:00
fix: Subscribe to document automatically on share (#8108)
This commit is contained in:
1 parent
a458690bfc
commit
e89c32424f
1 file changed
+27
@@ -0,0 +1,27 @@
|
||||
import subscriptionCreator from "@server/commands/subscriptionCreator";
|
||||
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({
|
||||
user,
|
||||
documentId: event.documentId,
|
||||
event: "documents.update",
|
||||
resubscribe: false,
|
||||
transaction,
|
||||
ip: event.ip,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user