1
0
Fork 0
miniflux/integration/integration.go

73 lines
2.2 KiB
Go
Raw Normal View History

2017-12-03 00:12:03 -05: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.
2018-08-25 00:51:50 -04:00
package integration // import "miniflux.app/integration"
2017-12-03 00:12:03 -05:00
import (
2018-08-25 00:51:50 -04:00
"miniflux.app/config"
"miniflux.app/integration/instapaper"
"miniflux.app/integration/nunuxkeeper"
"miniflux.app/integration/pinboard"
"miniflux.app/integration/pocket"
"miniflux.app/integration/wallabag"
"miniflux.app/logger"
"miniflux.app/model"
2017-12-03 00:12:03 -05:00
)
// SendEntry send the entry to the activated providers.
func SendEntry(cfg *config.Config, entry *model.Entry, integration *model.Integration) {
2017-12-03 00:12:03 -05:00
if integration.PinboardEnabled {
client := pinboard.NewClient(integration.PinboardToken)
2017-12-18 23:52:46 -05:00
err := client.AddBookmark(
entry.URL,
entry.Title,
integration.PinboardTags,
integration.PinboardMarkAsUnread,
)
2017-12-03 00:12:03 -05:00
if err != nil {
logger.Error("[Integration] UserID #%d: %v", integration.UserID, err)
2017-12-03 00:12:03 -05:00
}
}
if integration.InstapaperEnabled {
client := instapaper.NewClient(integration.InstapaperUsername, integration.InstapaperPassword)
2017-12-18 23:52:46 -05:00
if err := client.AddURL(entry.URL, entry.Title); err != nil {
logger.Error("[Integration] UserID #%d: %v", integration.UserID, err)
2017-12-18 23:52:46 -05:00
}
}
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] UserID #%d: %v", integration.UserID, err)
2017-12-03 00:12:03 -05:00
}
}
2018-02-25 14:49:08 -05:00
if integration.NunuxKeeperEnabled {
client := nunuxkeeper.NewClient(
integration.NunuxKeeperURL,
integration.NunuxKeeperAPIKey,
)
if err := client.AddEntry(entry.URL, entry.Title, entry.Content); err != nil {
logger.Error("[Integration] UserID #%d: %v", integration.UserID, err)
2018-02-25 14:49:08 -05:00
}
}
2018-05-20 16:31:56 -04:00
if integration.PocketEnabled {
client := pocket.NewClient(cfg.PocketConsumerKey(integration.PocketConsumerKey), integration.PocketAccessToken)
2018-05-20 16:31:56 -04:00
if err := client.AddURL(entry.URL, entry.Title); err != nil {
logger.Error("[Integration] UserID #%d: %v", integration.UserID, err)
}
}
2017-12-03 00:12:03 -05:00
}