From e5b2eab7270bfddecdb90910c82893780a43ba4f Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sun, 21 Feb 2021 08:34:07 +0100 Subject: [PATCH] Send full article content to wallabag --- integration/integration.go | 2 +- integration/wallabag/wallabag.go | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/integration/integration.go b/integration/integration.go index 90449d15..211ed5f1 100644 --- a/integration/integration.go +++ b/integration/integration.go @@ -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) } } diff --git a/integration/wallabag/wallabag.go b/integration/wallabag/wallabag.go index 786470f7..f6f3a651 100644 --- a/integration/wallabag/wallabag.go +++ b/integration/wallabag/wallabag.go @@ -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") } @@ -33,10 +34,10 @@ 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) @@ -44,7 +45,7 @@ func (c *Client) createEntry(accessToken, link, title string) error { 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) }