🐛 Bug fixes on notifications

This commit is contained in:
2024-12-09 23:34:21 +08:00
parent fdf2d28f51
commit 573ccc0478
2 changed files with 5 additions and 6 deletions

View File

@ -32,7 +32,7 @@ func getNotifications(c *fiber.Ctx) error {
if err := tx.
Limit(take).
Offset(offset).
Order("read_at DESC, created_at DESC").
Order("created_at DESC").
Find(&notifications).Error; err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
}
@ -49,7 +49,7 @@ func getNotificationCount(c *fiber.Ctx) error {
}
user := c.Locals("user").(models.Account)
tx := database.C.Where(&models.Notification{AccountID: user.ID}).Model(&models.Notification{})
tx := database.C.Where("account_id = ? AND read_at IS NULL", user.ID).Model(&models.Notification{})
var count int64
if err := tx.