Skip to content

Commit

Permalink
Send full article content to wallabag
Browse files Browse the repository at this point in the history
  • Loading branch information
Crocmagnon authored and fguillot committed Feb 21, 2021
1 parent bbf9343 commit e5b2eab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func SendEntry(entry *model.Entry, integration *model.Integration) {
integration.WallabagPassword,
)

if err := client.AddEntry(entry.URL, entry.Title); err != nil {
if err := client.AddEntry(entry.URL, entry.Title, entry.Content); err != nil {
logger.Error("[Integration] UserID #%d: %v", integration.UserID, err)
}
}
Expand Down
9 changes: 5 additions & 4 deletions integration/wallabag/wallabag.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ type Client struct {
}

// AddEntry sends a link to Wallabag.
func (c *Client) AddEntry(link, title string) error {
// Pass an empty string in `content` to let Wallabag fetch the article content.
func (c *Client) AddEntry(link, title, content string) error {
if c.baseURL == "" || c.clientID == "" || c.clientSecret == "" || c.username == "" || c.password == "" {
return fmt.Errorf("wallabag: missing credentials")
}
Expand All @@ -33,18 +34,18 @@ func (c *Client) AddEntry(link, title string) error {
return err
}

return c.createEntry(accessToken, link, title)
return c.createEntry(accessToken, link, title, content)
}

func (c *Client) createEntry(accessToken, link, title string) error {
func (c *Client) createEntry(accessToken, link, title, content string) error {
endpoint, err := getAPIEndpoint(c.baseURL, "/api/entries.json")
if err != nil {
return fmt.Errorf("wallbag: unable to get entries endpoint: %v", err)
}

clt := client.New(endpoint)
clt.WithAuthorization("Bearer " + accessToken)
response, err := clt.PostJSON(map[string]string{"url": link, "title": title})
response, err := clt.PostJSON(map[string]string{"url": link, "title": title, "content": content})
if err != nil {
return fmt.Errorf("wallabag: unable to post entry: %v", err)
}
Expand Down

0 comments on commit e5b2eab

Please sign in to comment.