diff options
author | Patrick <pmarschik@users.noreply.github.com> | 2018-09-20 03:19:24 +0200 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2018-09-19 18:19:24 -0700 |
commit | 2538eea1776e1d03d33465ad2001512caca93937 (patch) | |
tree | 021c417d5f31606fe50d7945872c4cda6cdc2060 /api | |
parent | 1d335390c2ac7c0feeb94fce89eefdae9a1e7c17 (diff) |
Add the possibility to override default user agent for each feed
Diffstat (limited to 'api')
-rw-r--r-- | api/feed.go | 1 | ||||
-rw-r--r-- | api/payload.go | 13 | ||||
-rw-r--r-- | api/subscription.go | 1 |
3 files changed, 12 insertions, 3 deletions
diff --git a/api/feed.go b/api/feed.go index e303f58..17bb73d 100644 --- a/api/feed.go +++ b/api/feed.go @@ -47,6 +47,7 @@ func (c *Controller) CreateFeed(w http.ResponseWriter, r *http.Request) { feedInfo.CategoryID, feedInfo.FeedURL, feedInfo.Crawler, + feedInfo.UserAgent, feedInfo.Username, feedInfo.Password, ) diff --git a/api/payload.go b/api/payload.go index ee1e41b..5acf0bb 100644 --- a/api/payload.go +++ b/api/payload.go @@ -26,15 +26,17 @@ type entriesResponse struct { type feedCreation struct { FeedURL string `json:"feed_url"` CategoryID int64 `json:"category_id"` + UserAgent string `json:"user_agent"` Username string `json:"username"` Password string `json:"password"` Crawler bool `json:"crawler"` } type subscriptionDiscovery struct { - URL string `json:"url"` - Username string `json:"username"` - Password string `json:"password"` + URL string `json:"url"` + UserAgent string `json:"user_agent"` + Username string `json:"username"` + Password string `json:"password"` } type feedModification struct { @@ -44,6 +46,7 @@ type feedModification struct { ScraperRules *string `json:"scraper_rules"` RewriteRules *string `json:"rewrite_rules"` Crawler *bool `json:"crawler"` + UserAgent *string `json:"user_agent"` Username *string `json:"username"` Password *string `json:"password"` CategoryID *int64 `json:"category_id"` @@ -74,6 +77,10 @@ func (f *feedModification) Update(feed *model.Feed) { feed.Crawler = *f.Crawler } + if f.UserAgent != nil { + feed.UserAgent = *f.UserAgent + } + if f.Username != nil { feed.Username = *f.Username } diff --git a/api/subscription.go b/api/subscription.go index 603b932..ff4c7cf 100644 --- a/api/subscription.go +++ b/api/subscription.go @@ -22,6 +22,7 @@ func (c *Controller) GetSubscriptions(w http.ResponseWriter, r *http.Request) { subscriptions, err := subscription.FindSubscriptions( subscriptionInfo.URL, + subscriptionInfo.UserAgent, subscriptionInfo.Username, subscriptionInfo.Password, ) |