1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

Add option to send only the URL to Wallabag

This commit is contained in:
jtagcat 2022-09-19 02:52:28 +03:00 committed by GitHub
parent 133a1f83e3
commit 3f64e4b943
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 110 additions and 65 deletions

View file

@ -20,11 +20,12 @@ type Client struct {
clientSecret string
username string
password string
onlyURL bool
}
// NewClient returns a new Wallabag client.
func NewClient(baseURL, clientID, clientSecret, username, password string) *Client {
return &Client{baseURL, clientID, clientSecret, username, password}
func NewClient(baseURL, clientID, clientSecret, username, password string, onlyURL bool) *Client {
return &Client{baseURL, clientID, clientSecret, username, password, onlyURL}
}
// AddEntry sends a link to Wallabag.
@ -48,9 +49,14 @@ func (c *Client) createEntry(accessToken, link, title, content string) error {
return fmt.Errorf("wallbag: unable to get entries endpoint: %v", err)
}
data := map[string]string{"url": link, "title": title}
if !c.onlyURL {
data["content"] = content
}
clt := client.New(endpoint)
clt.WithAuthorization("Bearer " + accessToken)
response, err := clt.PostJSON(map[string]string{"url": link, "title": title, "content": content})
response, err := clt.PostJSON(data)
if err != nil {
return fmt.Errorf("wallabag: unable to post entry: %v", err)
}