Fix removing likes notification
This commit is contained in:
parent
a9cc758624
commit
ef8abec7bf
|
@ -178,7 +178,7 @@ func Likes() http.HandlerFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the target's notification about this like.
|
// Remove the target's notification about this like.
|
||||||
models.RemoveSpecificNotification(targetUser.ID, models.NotificationLike, req.TableName, tableID)
|
models.RemoveSpecificNotificationAboutUser(targetUser.ID, currentUser.ID, models.NotificationLike, req.TableName, tableID)
|
||||||
} else {
|
} else {
|
||||||
if err := models.AddLike(currentUser, req.TableName, tableID); err != nil {
|
if err := models.AddLike(currentUser, req.TableName, tableID); err != nil {
|
||||||
SendJSON(w, http.StatusBadRequest, Response{
|
SendJSON(w, http.StatusBadRequest, Response{
|
||||||
|
|
|
@ -120,6 +120,16 @@ func RemoveSpecificNotification(userID uint64, t NotificationType, tableName str
|
||||||
return result.Error
|
return result.Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RemoveSpecificNotificationAboutUser to remove a specific table_name/id notification about a user,
|
||||||
|
// e.g. when removing a like on a photo.
|
||||||
|
func RemoveSpecificNotificationAboutUser(userID, aboutUserID uint64, t NotificationType, tableName string, tableID uint64) error {
|
||||||
|
result := DB.Where(
|
||||||
|
"user_id = ? AND about_user_id = ? AND type = ? AND table_name = ? AND table_id = ?",
|
||||||
|
userID, aboutUserID, t, tableName, tableID,
|
||||||
|
).Delete(&Notification{})
|
||||||
|
return result.Error
|
||||||
|
}
|
||||||
|
|
||||||
// RemoveSpecificNotificationBulk can remove notifications about several TableIDs of the same type,
|
// RemoveSpecificNotificationBulk can remove notifications about several TableIDs of the same type,
|
||||||
// e.g. to bulk remove new private photo upload notifications.
|
// e.g. to bulk remove new private photo upload notifications.
|
||||||
func RemoveSpecificNotificationBulk(users []*User, t NotificationType, tableName string, tableIDs []uint64) error {
|
func RemoveSpecificNotificationBulk(users []*User, t NotificationType, tableName string, tableIDs []uint64) error {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user