follow: Fix get watched item logic for followed thoughts

Before it could get two entries if user has two entries that had same id number for content and game ids.
This commit is contained in:
IRHM
2024-02-10 17:50:10 +00:00
parent 4afc32f9d1
commit e3fe047afd
+5 -1
View File
@@ -129,7 +129,11 @@ func getFollowsThoughts(db *gorm.DB, userId uint, mediaType string, mediaId stri
}
// Get list of followeds watcheds for this content
var fw []Watched
res = db.Where("(content_id = ? OR game_id = ?) AND user_id IN ?", contentOrGameId, contentOrGameId, followIds).Find(&fw)
if mediaType == "game" {
res = db.Where("game_id = ? AND user_id IN ?", contentOrGameId, followIds).Find(&fw)
} else {
res = db.Where("content_id = ? AND user_id IN ?", contentOrGameId, followIds).Find(&fw)
}
if res.Error != nil {
slog.Error("getFollows: Error finding followed watcheds from db.", "error", res.Error)
return []FollowThoughts{}, errors.New("failed to find followed watcheds")