fix lint
This commit is contained in:
@@ -28,7 +28,6 @@ linters:
|
||||
- importas
|
||||
- inamedparam
|
||||
- intrange
|
||||
- lll
|
||||
- maintidx
|
||||
- nestif
|
||||
- nlreturn
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package rss
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"text/template"
|
||||
@@ -185,12 +184,13 @@ func (s *server) rss(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest) // TODO: standardize error handling.
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Render and convert to RSS.
|
||||
rssObj := &feeds.Feed{
|
||||
Title: fmt.Sprintf("Zenfeed RSS - %s", ps.Encode()),
|
||||
Title: "Zenfeed RSS - " + ps.Encode(),
|
||||
Description: "Powered by Github Zenfeed - https://github.com/glidea/zenfeed. If you use Folo, please enable 'Appearance - Content - Render inline styles'",
|
||||
Items: make([]*feeds.Item, 0, len(queryResult.Feeds)),
|
||||
}
|
||||
@@ -203,6 +203,7 @@ func (s *server) rss(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if err = s.Config().contentHTMLTemplate.Execute(buf, feed.Labels.Map()); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -218,6 +219,7 @@ func (s *server) rss(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if err = rssObj.WriteRss(w); err != nil {
|
||||
log.Error(ctx, errors.Wrap(err, "write rss response"))
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package llm
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
oai "github.com/sashabaranov/go-openai"
|
||||
@@ -132,7 +131,6 @@ func (o *openai) Embedding(ctx context.Context, s string) (value []float32, err
|
||||
EncodingFormat: oai.EmbeddingEncodingFormatFloat,
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(s)
|
||||
return nil, errors.Wrap(err, "create embeddings")
|
||||
}
|
||||
if len(vec.Data) == 0 {
|
||||
|
||||
@@ -127,6 +127,7 @@ func (c *aggrChannel) Send(ctx context.Context, receiver Receiver, group *route.
|
||||
if receiver.Webhook != nil && c.webhook != nil {
|
||||
return c.send(ctx, receiver, group, c.webhook, "webhook")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -537,7 +537,7 @@ func TestConfig_Validate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
wantErr: true,
|
||||
errMsg: "invalid sub_route: invalid matcher: invalid matcher",
|
||||
errMsg: "invalid sub_route: invalid matchers: new label filter",
|
||||
},
|
||||
{
|
||||
name: "Valid nested sub-route",
|
||||
|
||||
@@ -101,7 +101,7 @@ type Rule struct {
|
||||
Label string
|
||||
}
|
||||
|
||||
func (r *Rule) Validate() error { //nolint:cyclop
|
||||
func (r *Rule) Validate() error { //nolint:cyclop,gocognit,funlen
|
||||
// If.
|
||||
if len(r.If) > 0 {
|
||||
if_, err := model.NewLabelFilters(r.If)
|
||||
@@ -358,6 +358,7 @@ func (r *rewriter) transformTextCrawl(ctx context.Context, crawler crawl.Crawler
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "crawl %s", url)
|
||||
}
|
||||
|
||||
return string(mdBytes), nil
|
||||
}
|
||||
|
||||
@@ -383,6 +384,7 @@ func (r *rewriter) transformTextHack(text string) string {
|
||||
text = strings.ReplaceAll(text, "```html", "")
|
||||
text = strings.ReplaceAll(text, "```markdown", "")
|
||||
text = strings.ReplaceAll(text, "```", "")
|
||||
|
||||
return text
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ func (c *local) Markdown(ctx context.Context, u string) ([]byte, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "fetch %s", u)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
|
||||
// Parse the response.
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
@@ -107,7 +107,7 @@ func (c *local) getRobotsData(ctx context.Context, host string) (*robotstxt.Robo
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "fetch %s", robotsURL)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
|
||||
// Parse the response.
|
||||
switch resp.StatusCode {
|
||||
@@ -117,11 +117,15 @@ func (c *local) getRobotsData(ctx context.Context, host string) (*robotstxt.Robo
|
||||
return nil, errors.Wrapf(err, "parse robots.txt from %s", robotsURL)
|
||||
}
|
||||
c.robotsDataCache.Store(host, data)
|
||||
|
||||
return data, nil
|
||||
|
||||
case http.StatusNotFound:
|
||||
data := &robotstxt.RobotsData{}
|
||||
c.robotsDataCache.Store(host, data)
|
||||
|
||||
return data, nil
|
||||
|
||||
case http.StatusUnauthorized, http.StatusForbidden:
|
||||
return nil, errors.Errorf("access to %s denied (status %d)", robotsURL, resp.StatusCode)
|
||||
default:
|
||||
@@ -145,7 +149,7 @@ func NewJina(token string) Crawler {
|
||||
}
|
||||
|
||||
func (c *jina) Markdown(ctx context.Context, u string) ([]byte, error) {
|
||||
proxyURL := fmt.Sprintf("https://r.jina.ai/%s", u)
|
||||
proxyURL := "https://r.jina.ai/" + u
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, proxyURL, nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "create request for %s", u)
|
||||
@@ -154,14 +158,14 @@ func (c *jina) Markdown(ctx context.Context, u string) ([]byte, error) {
|
||||
req.Header.Set("X-Engine", "browser")
|
||||
req.Header.Set("X-Robots-Txt", userAgent)
|
||||
if c.token != "" {
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", c.token))
|
||||
req.Header.Set("Authorization", "Bearer "+c.token)
|
||||
}
|
||||
|
||||
resp, err := c.hc.Do(req)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "fetch %s", proxyURL)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, errors.Errorf("received non-200 status code %d from %s", resp.StatusCode, proxyURL)
|
||||
|
||||
Reference in New Issue
Block a user