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/models/comments/helpers.go
2017-07-17 15:00:40 +02:00

23 lignes
882 o
Go

package comments
import (
"fmt"
"strconv"
"github.com/NyaaPantsu/nyaa/models"
"github.com/NyaaPantsu/nyaa/models/notifications"
"github.com/NyaaPantsu/nyaa/utils/publicSettings"
)
// When a new comment is added this is called
func NewCommentEvent(comment *models.Comment, torrent *models.Torrent) {
comment.Torrent = torrent
url := "/view/" + strconv.FormatUint(uint64(torrent.ID), 10)
if torrent.UploaderID > 0 {
torrent.Uploader.ParseSettings()
if torrent.Uploader.Settings.Get("new_comment") {
T, _, _ := publicSettings.TfuncAndLanguageWithFallback(torrent.Uploader.Language, torrent.Uploader.Language) // We need to send the notification to every user in their language
notifications.NotifyUser(torrent.Uploader, comment.Identifier(), fmt.Sprintf(T("new_comment_on_torrent"), torrent.Name), url, torrent.Uploader.Settings.Get("new_comment_email"))
}
}
}