aboutsummaryrefslogtreecommitdiffhomepage
path: root/integration
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2018-04-29 17:58:09 -0700
committerGravatar Frédéric Guillot <fred@miniflux.net>2018-04-29 17:58:09 -0700
commit7a1653a2e9e0802677d34f513828b33c0ef5c576 (patch)
treead1c8dfe22c362309be5f7e66fb0d76a62f01c56 /integration
parent31da4db14fdda364b1c72460a81e3ccce67ff7e8 (diff)
Make sure integrations are configured before to make any HTTP requests
Diffstat (limited to 'integration')
-rw-r--r--integration/instapaper/instapaper.go4
-rw-r--r--integration/integration.go8
-rw-r--r--integration/nunuxkeeper/nunuxkeeper.go4
-rw-r--r--integration/pinboard/pinboard.go4
-rw-r--r--integration/wallabag/wallabag.go4
5 files changed, 20 insertions, 4 deletions
diff --git a/integration/instapaper/instapaper.go b/integration/instapaper/instapaper.go
index 52d8ee1..ee44edd 100644
--- a/integration/instapaper/instapaper.go
+++ b/integration/instapaper/instapaper.go
@@ -19,6 +19,10 @@ type Client struct {
// AddURL sends a link to Instapaper.
func (c *Client) AddURL(link, title string) error {
+ if c.username == "" || c.password == "" {
+ return fmt.Errorf("instapaper: missing credentials")
+ }
+
values := url.Values{}
values.Add("url", link)
values.Add("title", title)
diff --git a/integration/integration.go b/integration/integration.go
index 05c7794..42e13f9 100644
--- a/integration/integration.go
+++ b/integration/integration.go
@@ -25,14 +25,14 @@ func SendEntry(entry *model.Entry, integration *model.Integration) {
)
if err != nil {
- logger.Error("[Integration] %v", err)
+ logger.Error("[Integration] UserID #%d: %v", integration.UserID, err)
}
}
if integration.InstapaperEnabled {
client := instapaper.NewClient(integration.InstapaperUsername, integration.InstapaperPassword)
if err := client.AddURL(entry.URL, entry.Title); err != nil {
- logger.Error("[Integration] %v", err)
+ logger.Error("[Integration] UserID #%d: %v", integration.UserID, err)
}
}
@@ -46,7 +46,7 @@ func SendEntry(entry *model.Entry, integration *model.Integration) {
)
if err := client.AddEntry(entry.URL, entry.Title); err != nil {
- logger.Error("[Integration] %v", err)
+ logger.Error("[Integration] UserID #%d: %v", integration.UserID, err)
}
}
@@ -57,7 +57,7 @@ func SendEntry(entry *model.Entry, integration *model.Integration) {
)
if err := client.AddEntry(entry.URL, entry.Title, entry.Content); err != nil {
- logger.Error("[Integration] %v", err)
+ logger.Error("[Integration] UserID #%d: %v", integration.UserID, err)
}
}
}
diff --git a/integration/nunuxkeeper/nunuxkeeper.go b/integration/nunuxkeeper/nunuxkeeper.go
index 4ea5c45..cb340ab 100644
--- a/integration/nunuxkeeper/nunuxkeeper.go
+++ b/integration/nunuxkeeper/nunuxkeeper.go
@@ -28,6 +28,10 @@ type Client struct {
// AddEntry sends an entry to Nunux Keeper.
func (c *Client) AddEntry(link, title, content string) error {
+ if c.baseURL == "" || c.apiKey == "" {
+ return fmt.Errorf("nunux-keeper: missing credentials")
+ }
+
doc := &Document{
Title: title,
Origin: link,
diff --git a/integration/pinboard/pinboard.go b/integration/pinboard/pinboard.go
index 54294ae..d34e4fe 100644
--- a/integration/pinboard/pinboard.go
+++ b/integration/pinboard/pinboard.go
@@ -18,6 +18,10 @@ type Client struct {
// AddBookmark sends a link to Pinboard.
func (c *Client) AddBookmark(link, title, tags string, markAsUnread bool) error {
+ if c.authToken == "" {
+ return fmt.Errorf("pinboard: missing credentials")
+ }
+
toRead := "no"
if markAsUnread {
toRead = "yes"
diff --git a/integration/wallabag/wallabag.go b/integration/wallabag/wallabag.go
index 58d9c5b..02a36b5 100644
--- a/integration/wallabag/wallabag.go
+++ b/integration/wallabag/wallabag.go
@@ -24,6 +24,10 @@ type Client struct {
// AddEntry sends a link to Wallabag.
func (c *Client) AddEntry(link, title string) error {
+ if c.baseURL == "" || c.clientID == "" || c.clientSecret == "" || c.username == "" || c.password == "" {
+ return fmt.Errorf("wallabag: missing credentials")
+ }
+
accessToken, err := c.getAccessToken()
if err != nil {
return err