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/create.go
2017-07-09 16:21:34 +02:00

23 lignes
534 o
Go

package comments
import (
"time"
"github.com/NyaaPantsu/nyaa/models"
"github.com/NyaaPantsu/nyaa/utils/cache"
)
func Create(content string, torrent *models.Torrent, user *models.User) (*models.Comment, error) {
comment := &models.Comment{TorrentID: torrent.ID, UserID: user.ID, Content: content, CreatedAt: time.Now()}
err := models.ORM.Create(comment).Error
if err != nil {
return comment, err
}
NewCommentEvent(comment, torrent)
comment.Torrent = torrent
cache.C.Delete(torrent.Identifier())
return comment, nil
}