fix: fix annotation filtering in article handlerUnverified
5264ada parent: 2b8e65c modified
internal/db/social.go +2 -0 | @@ -122,6 +122,8 @@ func (s *ArticleStore) ListAnnotations(ctx context.Context, feedURL, articleURL, | ||
| 122 | 122 | if articleURL != "" { |
| 123 | 123 | conds = append(conds, "a.article_url = ?") |
| 124 | 124 | args = append(args, articleURL) |
| 125 | + } else if feedURL != "" { | |
| 126 | + conds = append(conds, "(a.article_url = '' OR a.article_url IS NULL)") | |
| 125 | 127 | } |
| 126 | 128 | if authorDID != "" { |
| 127 | 129 | conds = append(conds, "a.author_did = ?") |
| @@ -122,6 +122,8 @@ func (s *ArticleStore) ListAnnotations(ctx context.Context, feedURL, articleURL, | |||
| 122 | if articleURL != "" { | 122 | if articleURL != "" { |
| 123 | conds = append(conds, "a.article_url = ?") | 123 | conds = append(conds, "a.article_url = ?") |
| 124 | args = append(args, articleURL) | 124 | args = append(args, articleURL) |
| 125 | + } else if feedURL != "" { | ||
| 126 | + conds = append(conds, "(a.article_url = '' OR a.article_url IS NULL)") | ||
| 125 | } | 127 | } |
| 126 | if authorDID != "" { | 128 | if authorDID != "" { |
| 127 | conds = append(conds, "a.author_did = ?") | 129 | conds = append(conds, "a.author_did = ?") |
modified
internal/server/articles_handler.go +1 -1 | @@ -254,7 +254,7 @@ func (s *Server) handleArticleDetail(w http.ResponseWriter, r *http.Request) { | ||
| 254 | 254 | |
| 255 | 255 | g.Go(func() error { |
| 256 | 256 | var err error |
| 257 | - annotations, err = s.dbs.Articles.ListAnnotations(gCtx, "", article.URL.String, "", 20, 0) | |
| 257 | + annotations, err = s.dbs.Articles.ListAnnotations(gCtx, article.FeedURL, article.URL.String, "", 20, 0) | |
| 258 | 258 | if err != nil { |
| 259 | 259 | s.logger.Warn("failed to list annotations", "error", err) |
| 260 | 260 | return nil |
| @@ -254,7 +254,7 @@ func (s *Server) handleArticleDetail(w http.ResponseWriter, r *http.Request) { | |||
| 254 | 254 | ||
| 255 | g.Go(func() error { | 255 | g.Go(func() error { |
| 256 | var err error | 256 | var err error |
| 257 | - annotations, err = s.dbs.Articles.ListAnnotations(gCtx, "", article.URL.String, "", 20, 0) | 257 | + annotations, err = s.dbs.Articles.ListAnnotations(gCtx, article.FeedURL, article.URL.String, "", 20, 0) |
| 258 | if err != nil { | 258 | if err != nil { |
| 259 | s.logger.Warn("failed to list annotations", "error", err) | 259 | s.logger.Warn("failed to list annotations", "error", err) |
| 260 | return nil | 260 | return nil |