fix(disqus): fix returned posts list not have parent post

This commit is contained in:
henry.chen
2024-01-02 19:09:37 +08:00
parent 7c938bf024
commit 9d71ca8198
2 changed files with 9 additions and 6 deletions

View File

@@ -204,7 +204,7 @@ func handleDisqusList(c *gin.Context) {
if artc != nil { if artc != nil {
dcs.Data.Thread = artc.Thread dcs.Data.Thread = artc.Thread
} }
postsList, err := internal.PostsList(slug, cursor) postsList, err := internal.PostsList(artc, cursor)
if err != nil { if err != nil {
logrus.Error("hadnleDisqusList.PostsList: ", err) logrus.Error("hadnleDisqusList.PostsList: ", err)
dcs.ErrNo = 0 dcs.ErrNo = 0

View File

@@ -17,11 +17,13 @@ import (
// disqus api // disqus api
const ( const (
apiPostsCount = "https://disqus.com/api/3.0/threads/set.json" apiPostsCount = "https://disqus.com/api/3.0/threads/set.json"
apiPostsList = "https://disqus.com/api/3.0/threads/listPosts.json" apiPostsList = "https://disqus.com/api/3.0/threads/listPostsThreaded"
apiPostCreate = "https://disqus.com/api/3.0/posts/create.json" apiPostCreate = "https://disqus.com/api/3.0/posts/create.json"
apiPostApprove = "https://disqus.com/api/3.0/posts/approve.json" apiPostApprove = "https://disqus.com/api/3.0/posts/approve.json"
apiThreadCreate = "https://disqus.com/api/3.0/threads/create.json" apiThreadCreate = "https://disqus.com/api/3.0/threads/create.json"
apiThreadDetails = "https://disqus.com/api/3.0/threads/details.json" apiThreadDetails = "https://disqus.com/api/3.0/threads/details.json"
disqusAPIKey = "E8Uh5l5fHZ6gD8U3KycjAIAk46f68Zw7C6eW8WSjZvCLXebZ7p0r1yrYDrLilk2F"
) )
func checkDisqusConfig() error { func checkDisqusConfig() error {
@@ -123,16 +125,17 @@ type postDetail struct {
} }
// PostsList 评论列表 // PostsList 评论列表
func PostsList(slug, cursor string) (*PostsListResp, error) { func PostsList(article *model.Article, cursor string) (*PostsListResp, error) {
if err := checkDisqusConfig(); err != nil { if err := checkDisqusConfig(); err != nil {
return nil, err return nil, err
} }
vals := url.Values{} vals := url.Values{}
vals.Set("api_key", config.Conf.EiBlogApp.Disqus.PublicKey) vals.Set("api_key", disqusAPIKey)
vals.Set("forum", config.Conf.EiBlogApp.Disqus.ShortName) vals.Set("forum", config.Conf.EiBlogApp.Disqus.ShortName)
vals.Set("thread:ident", "post-"+slug) vals.Set("thread", article.Thread)
vals.Set("cursor", cursor) vals.Set("cursor", cursor)
vals.Set("order", "popular")
vals.Set("limit", "50") vals.Set("limit", "50")
resp, err := httpGet(apiPostsList + "?" + vals.Encode()) resp, err := httpGet(apiPostsList + "?" + vals.Encode())
@@ -181,7 +184,7 @@ func PostCreate(pc *PostComment) (*PostCreateResp, error) {
return nil, err return nil, err
} }
vals := url.Values{} vals := url.Values{}
vals.Set("api_key", "E8Uh5l5fHZ6gD8U3KycjAIAk46f68Zw7C6eW8WSjZvCLXebZ7p0r1yrYDrLilk2F") vals.Set("api_key", disqusAPIKey)
vals.Set("message", pc.Message) vals.Set("message", pc.Message)
vals.Set("parent", pc.Parent) vals.Set("parent", pc.Parent)
vals.Set("thread", pc.Thread) vals.Set("thread", pc.Thread)