mirror of
https://github.com/outline/outline.git
synced 2026-04-29 22:19:32 -05: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
33 lines
938 B
TypeScript
33 lines
938 B
TypeScript
import { NotificationEventType } from "@shared/types";
|
|
import { Notification, User } from "@server/models";
|
|
import { CollectionUserEvent } from "@server/types";
|
|
import { BaseTask, TaskPriority } from "./base/BaseTask";
|
|
|
|
export default class CollectionAddUserNotificationsTask extends BaseTask<CollectionUserEvent> {
|
|
public async perform(event: CollectionUserEvent) {
|
|
const recipient = await User.findByPk(event.userId);
|
|
if (!recipient) {
|
|
return;
|
|
}
|
|
|
|
if (
|
|
!recipient.isSuspended &&
|
|
recipient.subscribedToEventType(NotificationEventType.AddUserToCollection)
|
|
) {
|
|
await Notification.create({
|
|
event: NotificationEventType.AddUserToCollection,
|
|
userId: event.userId,
|
|
actorId: event.actorId,
|
|
teamId: event.teamId,
|
|
collectionId: event.collectionId,
|
|
});
|
|
}
|
|
}
|
|
|
|
public get options() {
|
|
return {
|
|
priority: TaskPriority.Background,
|
|
};
|
|
}
|
|
}
|