Skip to content

Commit

Permalink
fixed socket and emited evnt for password expire notifying the user
Browse files Browse the repository at this point in the history
  • Loading branch information
soleil00 committed Jul 11, 2024
1 parent bfa3e5f commit 2414aae
Show file tree
Hide file tree
Showing 4 changed files with 306 additions and 350 deletions.
5 changes: 5 additions & 0 deletions src/controllers/notificationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ import { Request, Response } from "express";
import Notification from "../sequelize/models/Notification";
import { UserAttributes } from "../sequelize/models/users";
import eventEmmiter from "../events/emmiter";
import { notificationEmitter } from "../utils/server";

export const getUserNotifications = async (req: Request, res: Response) => {
//@ts-ignore
const currentUser: UserAttributes = req.user;
try {
const userNotifications = await Notification.findAll({ where: { userId: currentUser.id } });

const nots = userNotifications.map((n) => n.dataValues);

notificationEmitter.emit("userNotifications", nots);

return res.status(200).json({
message: "user notification",
notifications: userNotifications,
Expand Down
Loading

0 comments on commit 2414aae

Please sign in to comment.