Notifications interface (#5354)

Co-authored-by: Apoorv Mishra <apoorvmishra101092@gmail.com>
This commit is contained in:
Tom Moor
2023-05-20 10:47:32 -04:00
committed by GitHub
parent b1e2ff0713
commit ea885133ac
49 changed files with 1918 additions and 163 deletions

View File

@@ -13,6 +13,7 @@ import {
Star,
Team,
Subscription,
Notification,
} from "@server/models";
import {
presentComment,
@@ -25,6 +26,7 @@ import {
presentSubscription,
presentTeam,
} from "@server/presenters";
import presentNotification from "@server/presenters/notification";
import { Event } from "../../types";
export default class WebsocketsProcessor {
@@ -390,6 +392,17 @@ export default class WebsocketsProcessor {
});
}
case "notifications.create":
case "notifications.update": {
const notification = await Notification.findByPk(event.modelId);
if (!notification) {
return;
}
const data = await presentNotification(notification);
return socketio.to(`user-${event.userId}`).emit(event.name, data);
}
case "stars.create":
case "stars.update": {
const star = await Star.findByPk(event.modelId);