Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Adds a calllback function on type to update anidbid when a tag is accepted

Cette révision appartient à :
akuma06 2017-08-01 00:05:30 +02:00
Parent 6f983260ae
révision a456abe06e

Voir le fichier

@ -3,12 +3,15 @@ package tags
import (
"fmt"
"github.com/NyaaPantsu/nyaa/models/torrents"
"github.com/NyaaPantsu/nyaa/config"
"github.com/NyaaPantsu/nyaa/models"
"github.com/NyaaPantsu/nyaa/models/users"
"github.com/NyaaPantsu/nyaa/utils/log"
)
// Filter check if a tag type has reached the maximal votes and removes the other tag of the same type
func Filter(tag string, tagType string, torrentID uint) bool {
if torrentID == 0 || tagType == "" || tag == "" {
return false
@ -42,8 +45,22 @@ func Filter(tag string, tagType string, torrentID uint) bool {
tagSum.UserID = 0 // System ID
tagSum.Weight = config.Get().Torrents.Tags.MaxWeight // Overriden to the maximal value
models.ORM.Save(&tagSum) // We only add back the tag accepted
callbackOnType(&tagSum)
return true
}
}
return false
}
func callbackOnType(tag *models.Tag) {
switch tag.Type {
case "anidbid", "vndbid":
if tag.Accepted && tag.TorrentID > 0 {
torrent, err := torrents.FindByID(tag.TorrentID)
if err == nil {
torrent.DbID = tag.Tag
torrent.Update(false)
}
}
}
}