Send full article content to wallabag
This commit is contained in:
parent
bbf93430b7
commit
e5b2eab727
2 changed files with 6 additions and 5 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue