mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
fix early return when fetching artwork comments
This commit is contained in:
+21
-16
@@ -316,22 +316,6 @@ func GetArtworkByID(r *http.Request, id string, full bool) (*Illust, error) {
|
||||
}
|
||||
illust2.RelatedWorks = related
|
||||
}()
|
||||
|
||||
// Get reader comments
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
// if illust.CommentDisabled == 1 {
|
||||
// return
|
||||
// }
|
||||
comments, err := GetArtworkComments(r, id)
|
||||
if err != nil {
|
||||
cerr <- err
|
||||
return
|
||||
}
|
||||
illust2.CommentsList = comments
|
||||
}()
|
||||
}
|
||||
|
||||
// Get basic illust information
|
||||
@@ -433,6 +417,27 @@ func GetArtworkByID(r *http.Request, id string, full bool) (*Illust, error) {
|
||||
illust.RecentWorks = recent
|
||||
}()
|
||||
}
|
||||
|
||||
// Get reader comments
|
||||
//
|
||||
// Only fetch the comments if 'full' is requested and comments are not disabled (illust.CommentDisabled != 1).
|
||||
// This check needs to happen *after* fetching the basic artwork information, since that's when
|
||||
// 'CommentDisabled' is populated. If we check it too early, it would default to 0 (enabled),
|
||||
// leading to an invalid API call to fetch comments even when they are disabled, causing an HTTP 500 error
|
||||
// on our end when we receive HTTP 400 from the Pixiv API as a result.
|
||||
if full && illust.CommentDisabled != 1 {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
comments, err := GetArtworkComments(r, id)
|
||||
if err != nil {
|
||||
cerr <- err
|
||||
return
|
||||
}
|
||||
illust2.CommentsList = comments
|
||||
}()
|
||||
}
|
||||
}()
|
||||
|
||||
wg.Wait()
|
||||
|
||||
Reference in New Issue
Block a user