mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
a226889143
* Update task scheduling to use instance method * Delete update_task_schedule.sh * Applied automatic fixes * tsc --------- Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com> Co-authored-by: Tom Moor <tom@getoutline.com>
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { Op } from "sequelize";
|
|
import { GroupUser } from "@server/models";
|
|
import { DocumentGroupEvent, DocumentUserEvent } from "@server/types";
|
|
import BaseTask, { TaskPriority } from "./BaseTask";
|
|
import DocumentAddUserNotificationsTask from "./DocumentAddUserNotificationsTask";
|
|
|
|
export default class DocumentAddGroupNotificationsTask extends BaseTask<DocumentGroupEvent> {
|
|
public async perform(event: DocumentGroupEvent) {
|
|
await GroupUser.findAllInBatches<GroupUser>(
|
|
{
|
|
where: {
|
|
groupId: event.modelId,
|
|
userId: {
|
|
[Op.ne]: event.actorId,
|
|
},
|
|
},
|
|
batchLimit: 10,
|
|
},
|
|
async (groupUsers) => {
|
|
await Promise.all(
|
|
groupUsers.map(async (groupUser) => {
|
|
await new DocumentAddUserNotificationsTask().schedule({
|
|
...event,
|
|
name: "documents.add_user",
|
|
modelId: event.data.membershipId,
|
|
userId: groupUser.userId,
|
|
} as DocumentUserEvent);
|
|
})
|
|
);
|
|
}
|
|
);
|
|
}
|
|
|
|
public get options() {
|
|
return {
|
|
priority: TaskPriority.Background,
|
|
};
|
|
}
|
|
}
|