From 2538eea1776e1d03d33465ad2001512caca93937 Mon Sep 17 00:00:00 2001 From: Patrick Date: Thu, 20 Sep 2018 03:19:24 +0200 Subject: Add the possibility to override default user agent for each feed --- api/feed.go | 1 + api/payload.go | 13 ++++++++++--- api/subscription.go | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'api') 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, ) -- cgit v1.2.3