mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
42959d66db
* wip * Implementation complete * tidying * test * Address feedback * Remove duplicative retry logic from UpdateDocumentsPopularityScoreTask. Now that we're split across many runs this is not neccessary * Refactor to subclass, config to instance * Refactor BaseTask to named export * fix: Missing partition * tsc * Feedback
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 "./base/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,
|
|
};
|
|
}
|
|
}
|