Skip to content

Commit

Permalink
fix(read-norification): Change the unread on all notification
Browse files Browse the repository at this point in the history
  • Loading branch information
cyusasnave committed Jul 23, 2024
1 parent b73ddb7 commit 56a1340
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/__test__/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,9 @@ describe("SERVER API TEST", () => {
.send({ id: "97dcfe1e-0686-4876-808a-f3d3ec36c7ff" })
.set("Authorization", `Bearer ${buyer_token}`)
.expect(500);
expect(body.status).toStrictEqual("SERVER ERROR");
expect(body.message).toBe("Something went wrong!");
});
expect(body.status).toStrictEqual("SERVER ERROR");
expect(body.message).toBe("Something went wrong!");
});

it("should return 500 when something went wrong on getting all sales", async () => {
(read_function as jest.Mock).mockRejectedValueOnce(new Error("Test error"));
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/notificationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export const mark_all_as_read = async (req: Request, res: Response) => {
const user = (req as any).user;
const userId = user?.id;

const condition = { where: { userId } };
const condition = { where: { userId, unread: true } };

const notifications: NotificationAttributes[] = await read_function<
NotificationAttributes[]
Expand Down
2 changes: 1 addition & 1 deletion src/utils/socket.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const config = (server: http.Server) => {
socket.emit("chat messages", messages);

const unreadNotifications = await DBNotification.findAll({
where: { userId, unread: true },
where: { userId },
});

socket.emit("notifications", unreadNotifications);
Expand Down

0 comments on commit 56a1340

Please sign in to comment.