2017-12-03 06:12:03 +01:00
|
|
|
// Copyright 2017 Frédéric Guillot. All rights reserved.
|
|
|
|
// Use of this source code is governed by the Apache 2.0
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package integration
|
|
|
|
|
|
|
|
import (
|
2017-12-13 06:48:13 +01:00
|
|
|
"github.com/miniflux/miniflux/integration/instapaper"
|
|
|
|
"github.com/miniflux/miniflux/integration/pinboard"
|
2017-12-19 05:52:46 +01:00
|
|
|
"github.com/miniflux/miniflux/integration/wallabag"
|
2017-12-16 03:55:57 +01:00
|
|
|
"github.com/miniflux/miniflux/logger"
|
2017-12-13 06:48:13 +01:00
|
|
|
"github.com/miniflux/miniflux/model"
|
2017-12-03 06:12:03 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// SendEntry send the entry to the activated providers.
|
|
|
|
func SendEntry(entry *model.Entry, integration *model.Integration) {
|
|
|
|
if integration.PinboardEnabled {
|
|
|
|
client := pinboard.NewClient(integration.PinboardToken)
|
2017-12-19 05:52:46 +01:00
|
|
|
err := client.AddBookmark(
|
|
|
|
entry.URL,
|
|
|
|
entry.Title,
|
|
|
|
integration.PinboardTags,
|
|
|
|
integration.PinboardMarkAsUnread,
|
|
|
|
)
|
|
|
|
|
2017-12-03 06:12:03 +01:00
|
|
|
if err != nil {
|
2017-12-19 05:52:46 +01:00
|
|
|
logger.Error("[Integration] %v", err)
|
2017-12-03 06:12:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if integration.InstapaperEnabled {
|
|
|
|
client := instapaper.NewClient(integration.InstapaperUsername, integration.InstapaperPassword)
|
2017-12-19 05:52:46 +01:00
|
|
|
if err := client.AddURL(entry.URL, entry.Title); err != nil {
|
|
|
|
logger.Error("[Integration] %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if integration.WallabagEnabled {
|
|
|
|
client := wallabag.NewClient(
|
|
|
|
integration.WallabagURL,
|
|
|
|
integration.WallabagClientID,
|
|
|
|
integration.WallabagClientSecret,
|
|
|
|
integration.WallabagUsername,
|
|
|
|
integration.WallabagPassword,
|
|
|
|
)
|
|
|
|
|
|
|
|
if err := client.AddEntry(entry.URL, entry.Title); err != nil {
|
|
|
|
logger.Error("[Integration] %v", err)
|
2017-12-03 06:12:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|