Skip to content

Commit

Permalink
Merge pull request #89 from atlp-rwanda/fix-category
Browse files Browse the repository at this point in the history
fix: fixed category fetching allowing all user to fetch availabe catgeories
  • Loading branch information
teerenzo authored and soleil00 committed Jul 17, 2024
2 parents b54207b + 3beabba commit 9e5dacc
Show file tree
Hide file tree
Showing 10 changed files with 375 additions and 425 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/uploads
/.vscode
/dist
/demo.tsx
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 allNots = userNotifications.map((not) => not.dataValues);

notificationEmitter.emit("notifications", allNots);

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

0 comments on commit 9e5dacc

Please sign in to comment.