Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/service/notifier/notifier.go

30 lignes
914 o
Go
Brut Vue normale Historique

2017-05-20 20:53:05 +02:00
package notifierService
import (
"github.com/NyaaPantsu/nyaa/db"
"github.com/NyaaPantsu/nyaa/model"
)
// NotifyUser : Notify a user with a notification according to his settings
2017-05-22 00:22:42 +02:00
func NotifyUser(user *model.User, name string, msg string, url string, email bool) {
2017-05-24 09:11:13 +02:00
if user.ID > 0 {
2017-05-21 00:02:57 +02:00
notification := model.NewNotification(name, msg, url)
notification.UserID = user.ID
2017-05-21 00:29:07 +02:00
db.ORM.Create(&notification)
2017-05-20 20:53:05 +02:00
// TODO: Email notification
2017-05-24 09:11:13 +02:00
/* if email {
}*/
2017-05-20 20:53:05 +02:00
}
}
// ToggleReadNotification : Make a notification as read according to its identifier
2017-05-24 09:11:13 +02:00
func ToggleReadNotification(identifier string, id uint) { //
2017-05-20 20:53:05 +02:00
db.ORM.Model(&model.Notification{}).Where("identifier = ? AND user_id = ?", identifier, id).Updates(model.Notification{Read: true})
2017-05-21 00:02:57 +02:00
}
// DeleteAllNotifications : Erase notifications from a user
2017-05-24 09:11:13 +02:00
func DeleteAllNotifications(id uint) { //
2017-05-21 00:02:57 +02:00
db.ORM.Where("user_id = ?", id).Delete(&model.Notification{})
2017-05-24 09:11:13 +02:00
}