Allow ignore_http_cache field to be changed via API

This commit is contained in:
Frédéric Guillot 2020-12-13 20:31:19 -08:00 committed by fguillot
parent 5922a7a051
commit 4e5240c5ac
10 changed files with 196 additions and 146 deletions

View file

@ -132,7 +132,7 @@ func (h *handler) findEntries(w http.ResponseWriter, r *http.Request, feedID int
} }
func (h *handler) setEntryStatus(w http.ResponseWriter, r *http.Request) { func (h *handler) setEntryStatus(w http.ResponseWriter, r *http.Request) {
entryIDs, status, err := decodeEntryStatusPayload(r.Body) entryIDs, status, err := decodeEntryStatusRequest(r.Body)
if err != nil { if err != nil {
json.BadRequest(w, r, errors.New("Invalid JSON payload")) json.BadRequest(w, r, errors.New("Invalid JSON payload"))
return return

View file

@ -14,7 +14,7 @@ import (
) )
func (h *handler) createFeed(w http.ResponseWriter, r *http.Request) { func (h *handler) createFeed(w http.ResponseWriter, r *http.Request) {
feedInfo, err := decodeFeedCreationPayload(r.Body) feedInfo, err := decodeFeedCreationRequest(r.Body)
if err != nil { if err != nil {
json.BadRequest(w, r, err) json.BadRequest(w, r, err)
return return
@ -61,11 +61,7 @@ func (h *handler) createFeed(w http.ResponseWriter, r *http.Request) {
return return
} }
type result struct { json.Created(w, r, &feedCreationResponse{FeedID: feed.ID})
FeedID int64 `json:"feed_id"`
}
json.Created(w, r, &result{FeedID: feed.ID})
} }
func (h *handler) refreshFeed(w http.ResponseWriter, r *http.Request) { func (h *handler) refreshFeed(w http.ResponseWriter, r *http.Request) {
@ -103,7 +99,7 @@ func (h *handler) refreshAllFeeds(w http.ResponseWriter, r *http.Request) {
func (h *handler) updateFeed(w http.ResponseWriter, r *http.Request) { func (h *handler) updateFeed(w http.ResponseWriter, r *http.Request) {
feedID := request.RouteInt64Param(r, "feedID") feedID := request.RouteInt64Param(r, "feedID")
feedChanges, err := decodeFeedModificationPayload(r.Body) feedChanges, err := decodeFeedModificationRequest(r.Body)
if err != nil { if err != nil {
json.BadRequest(w, r, err) json.BadRequest(w, r, err)
return return

View file

@ -30,7 +30,7 @@ func (h *handler) feedIcon(w http.ResponseWriter, r *http.Request) {
return return
} }
json.OK(w, r, &feedIcon{ json.OK(w, r, &feedIconResponse{
ID: icon.ID, ID: icon.ID,
MimeType: icon.MimeType, MimeType: icon.MimeType,
Data: icon.DataURL(), Data: icon.DataURL(),

View file

@ -12,7 +12,7 @@ import (
"miniflux.app/model" "miniflux.app/model"
) )
type feedIcon struct { type feedIconResponse struct {
ID int64 `json:"id"` ID int64 `json:"id"`
MimeType string `json:"mime_type"` MimeType string `json:"mime_type"`
Data string `json:"data"` Data string `json:"data"`
@ -23,7 +23,31 @@ type entriesResponse struct {
Entries model.Entries `json:"entries"` Entries model.Entries `json:"entries"`
} }
type feedCreation struct { type subscriptionDiscoveryRequest struct {
URL string `json:"url"`
UserAgent string `json:"user_agent"`
Username string `json:"username"`
Password string `json:"password"`
FetchViaProxy bool `json:"fetch_via_proxy"`
}
func decodeSubscriptionDiscoveryRequest(r io.ReadCloser) (*subscriptionDiscoveryRequest, error) {
defer r.Close()
var s subscriptionDiscoveryRequest
decoder := json.NewDecoder(r)
if err := decoder.Decode(&s); err != nil {
return nil, fmt.Errorf("invalid JSON payload: %v", err)
}
return &s, nil
}
type feedCreationResponse struct {
FeedID int64 `json:"feed_id"`
}
type feedCreationRequest struct {
FeedURL string `json:"feed_url"` FeedURL string `json:"feed_url"`
CategoryID int64 `json:"category_id"` CategoryID int64 `json:"category_id"`
UserAgent string `json:"user_agent"` UserAgent string `json:"user_agent"`
@ -37,15 +61,19 @@ type feedCreation struct {
KeeplistRules string `json:"keeplist_rules"` KeeplistRules string `json:"keeplist_rules"`
} }
type subscriptionDiscovery struct { func decodeFeedCreationRequest(r io.ReadCloser) (*feedCreationRequest, error) {
URL string `json:"url"` defer r.Close()
UserAgent string `json:"user_agent"`
Username string `json:"username"` var fc feedCreationRequest
Password string `json:"password"` decoder := json.NewDecoder(r)
FetchViaProxy bool `json:"fetch_via_proxy"` if err := decoder.Decode(&fc); err != nil {
return nil, fmt.Errorf("Invalid JSON payload: %v", err)
} }
type feedModification struct { return &fc, nil
}
type feedModificationRequest struct {
FeedURL *string `json:"feed_url"` FeedURL *string `json:"feed_url"`
SiteURL *string `json:"site_url"` SiteURL *string `json:"site_url"`
Title *string `json:"title"` Title *string `json:"title"`
@ -59,9 +87,11 @@ type feedModification struct {
Password *string `json:"password"` Password *string `json:"password"`
CategoryID *int64 `json:"category_id"` CategoryID *int64 `json:"category_id"`
Disabled *bool `json:"disabled"` Disabled *bool `json:"disabled"`
IgnoreHTTPCache *bool `json:"ignore_http_cache"`
FetchViaProxy *bool `json:"fetch_via_proxy"`
} }
func (f *feedModification) Update(feed *model.Feed) { func (f *feedModificationRequest) Update(feed *model.Feed) {
if f.FeedURL != nil && *f.FeedURL != "" { if f.FeedURL != nil && *f.FeedURL != "" {
feed.FeedURL = *f.FeedURL feed.FeedURL = *f.FeedURL
} }
@ -113,9 +143,41 @@ func (f *feedModification) Update(feed *model.Feed) {
if f.Disabled != nil { if f.Disabled != nil {
feed.Disabled = *f.Disabled feed.Disabled = *f.Disabled
} }
if f.IgnoreHTTPCache != nil {
feed.IgnoreHTTPCache = *f.IgnoreHTTPCache
} }
type userModification struct { if f.FetchViaProxy != nil {
feed.FetchViaProxy = *f.FetchViaProxy
}
}
func decodeFeedModificationRequest(r io.ReadCloser) (*feedModificationRequest, error) {
defer r.Close()
var feed feedModificationRequest
decoder := json.NewDecoder(r)
if err := decoder.Decode(&feed); err != nil {
return nil, fmt.Errorf("Unable to decode feed modification JSON object: %v", err)
}
return &feed, nil
}
func decodeUserCreationRequest(r io.ReadCloser) (*model.User, error) {
defer r.Close()
var user model.User
decoder := json.NewDecoder(r)
if err := decoder.Decode(&user); err != nil {
return nil, fmt.Errorf("Unable to decode user modification JSON object: %v", err)
}
return &user, nil
}
type userModificationRequest struct {
Username *string `json:"username"` Username *string `json:"username"`
Password *string `json:"password"` Password *string `json:"password"`
IsAdmin *bool `json:"is_admin"` IsAdmin *bool `json:"is_admin"`
@ -126,7 +188,7 @@ type userModification struct {
EntriesPerPage *int `json:"entries_per_page"` EntriesPerPage *int `json:"entries_per_page"`
} }
func (u *userModification) Update(user *model.User) { func (u *userModificationRequest) Update(user *model.User) {
if u.Username != nil { if u.Username != nil {
user.Username = *u.Username user.Username = *u.Username
} }
@ -160,10 +222,10 @@ func (u *userModification) Update(user *model.User) {
} }
} }
func decodeUserModificationPayload(r io.ReadCloser) (*userModification, error) { func decodeUserModificationRequest(r io.ReadCloser) (*userModificationRequest, error) {
defer r.Close() defer r.Close()
var user userModification var user userModificationRequest
decoder := json.NewDecoder(r) decoder := json.NewDecoder(r)
if err := decoder.Decode(&user); err != nil { if err := decoder.Decode(&user); err != nil {
return nil, fmt.Errorf("Unable to decode user modification JSON object: %v", err) return nil, fmt.Errorf("Unable to decode user modification JSON object: %v", err)
@ -172,31 +234,7 @@ func decodeUserModificationPayload(r io.ReadCloser) (*userModification, error) {
return &user, nil return &user, nil
} }
func decodeUserCreationPayload(r io.ReadCloser) (*model.User, error) { func decodeEntryStatusRequest(r io.ReadCloser) ([]int64, string, error) {
defer r.Close()
var user model.User
decoder := json.NewDecoder(r)
if err := decoder.Decode(&user); err != nil {
return nil, fmt.Errorf("Unable to decode user modification JSON object: %v", err)
}
return &user, nil
}
func decodeURLPayload(r io.ReadCloser) (*subscriptionDiscovery, error) {
defer r.Close()
var s subscriptionDiscovery
decoder := json.NewDecoder(r)
if err := decoder.Decode(&s); err != nil {
return nil, fmt.Errorf("invalid JSON payload: %v", err)
}
return &s, nil
}
func decodeEntryStatusPayload(r io.ReadCloser) ([]int64, string, error) {
type payload struct { type payload struct {
EntryIDs []int64 `json:"entry_ids"` EntryIDs []int64 `json:"entry_ids"`
Status string `json:"status"` Status string `json:"status"`
@ -212,30 +250,6 @@ func decodeEntryStatusPayload(r io.ReadCloser) ([]int64, string, error) {
return p.EntryIDs, p.Status, nil return p.EntryIDs, p.Status, nil
} }
func decodeFeedCreationPayload(r io.ReadCloser) (*feedCreation, error) {
defer r.Close()
var fc feedCreation
decoder := json.NewDecoder(r)
if err := decoder.Decode(&fc); err != nil {
return nil, fmt.Errorf("invalid JSON payload: %v", err)
}
return &fc, nil
}
func decodeFeedModificationPayload(r io.ReadCloser) (*feedModification, error) {
defer r.Close()
var feed feedModification
decoder := json.NewDecoder(r)
if err := decoder.Decode(&feed); err != nil {
return nil, fmt.Errorf("Unable to decode feed modification JSON object: %v", err)
}
return &feed, nil
}
type categoryRequest struct { type categoryRequest struct {
Title string `json:"title"` Title string `json:"title"`
} }

View file

@ -12,129 +12,129 @@ import (
func TestUpdateFeedURL(t *testing.T) { func TestUpdateFeedURL(t *testing.T) {
feedURL := "http://example.com/" feedURL := "http://example.com/"
changes := &feedModification{FeedURL: &feedURL} changes := &feedModificationRequest{FeedURL: &feedURL}
feed := &model.Feed{FeedURL: "http://example.org/"} feed := &model.Feed{FeedURL: "http://example.org/"}
changes.Update(feed) changes.Update(feed)
if feed.FeedURL != feedURL { if feed.FeedURL != feedURL {
t.Fatalf(`Unexpected value, got %q instead of %q`, feed.FeedURL, feedURL) t.Errorf(`Unexpected value, got %q instead of %q`, feed.FeedURL, feedURL)
} }
} }
func TestUpdateFeedURLWithEmptyString(t *testing.T) { func TestUpdateFeedURLWithEmptyString(t *testing.T) {
feedURL := "" feedURL := ""
changes := &feedModification{FeedURL: &feedURL} changes := &feedModificationRequest{FeedURL: &feedURL}
feed := &model.Feed{FeedURL: "http://example.org/"} feed := &model.Feed{FeedURL: "http://example.org/"}
changes.Update(feed) changes.Update(feed)
if feed.FeedURL == feedURL { if feed.FeedURL == feedURL {
t.Fatal(`The FeedURL should not be modified`) t.Error(`The FeedURL should not be modified`)
} }
} }
func TestUpdateFeedURLWhenNotSet(t *testing.T) { func TestUpdateFeedURLWhenNotSet(t *testing.T) {
changes := &feedModification{} changes := &feedModificationRequest{}
feed := &model.Feed{FeedURL: "http://example.org/"} feed := &model.Feed{FeedURL: "http://example.org/"}
changes.Update(feed) changes.Update(feed)
if feed.FeedURL != "http://example.org/" { if feed.FeedURL != "http://example.org/" {
t.Fatal(`The FeedURL should not be modified`) t.Error(`The FeedURL should not be modified`)
} }
} }
func TestUpdateFeedSiteURL(t *testing.T) { func TestUpdateFeedSiteURL(t *testing.T) {
siteURL := "http://example.com/" siteURL := "http://example.com/"
changes := &feedModification{SiteURL: &siteURL} changes := &feedModificationRequest{SiteURL: &siteURL}
feed := &model.Feed{SiteURL: "http://example.org/"} feed := &model.Feed{SiteURL: "http://example.org/"}
changes.Update(feed) changes.Update(feed)
if feed.SiteURL != siteURL { if feed.SiteURL != siteURL {
t.Fatalf(`Unexpected value, got %q instead of %q`, feed.SiteURL, siteURL) t.Errorf(`Unexpected value, got %q instead of %q`, feed.SiteURL, siteURL)
} }
} }
func TestUpdateFeedSiteURLWithEmptyString(t *testing.T) { func TestUpdateFeedSiteURLWithEmptyString(t *testing.T) {
siteURL := "" siteURL := ""
changes := &feedModification{FeedURL: &siteURL} changes := &feedModificationRequest{FeedURL: &siteURL}
feed := &model.Feed{SiteURL: "http://example.org/"} feed := &model.Feed{SiteURL: "http://example.org/"}
changes.Update(feed) changes.Update(feed)
if feed.SiteURL == siteURL { if feed.SiteURL == siteURL {
t.Fatal(`The FeedURL should not be modified`) t.Error(`The FeedURL should not be modified`)
} }
} }
func TestUpdateFeedSiteURLWhenNotSet(t *testing.T) { func TestUpdateFeedSiteURLWhenNotSet(t *testing.T) {
changes := &feedModification{} changes := &feedModificationRequest{}
feed := &model.Feed{SiteURL: "http://example.org/"} feed := &model.Feed{SiteURL: "http://example.org/"}
changes.Update(feed) changes.Update(feed)
if feed.SiteURL != "http://example.org/" { if feed.SiteURL != "http://example.org/" {
t.Fatal(`The SiteURL should not be modified`) t.Error(`The SiteURL should not be modified`)
} }
} }
func TestUpdateFeedTitle(t *testing.T) { func TestUpdateFeedTitle(t *testing.T) {
title := "Example 2" title := "Example 2"
changes := &feedModification{Title: &title} changes := &feedModificationRequest{Title: &title}
feed := &model.Feed{Title: "Example"} feed := &model.Feed{Title: "Example"}
changes.Update(feed) changes.Update(feed)
if feed.Title != title { if feed.Title != title {
t.Fatalf(`Unexpected value, got %q instead of %q`, feed.Title, title) t.Errorf(`Unexpected value, got %q instead of %q`, feed.Title, title)
} }
} }
func TestUpdateFeedTitleWithEmptyString(t *testing.T) { func TestUpdateFeedTitleWithEmptyString(t *testing.T) {
title := "" title := ""
changes := &feedModification{Title: &title} changes := &feedModificationRequest{Title: &title}
feed := &model.Feed{Title: "Example"} feed := &model.Feed{Title: "Example"}
changes.Update(feed) changes.Update(feed)
if feed.Title == title { if feed.Title == title {
t.Fatal(`The Title should not be modified`) t.Error(`The Title should not be modified`)
} }
} }
func TestUpdateFeedTitleWhenNotSet(t *testing.T) { func TestUpdateFeedTitleWhenNotSet(t *testing.T) {
changes := &feedModification{} changes := &feedModificationRequest{}
feed := &model.Feed{Title: "Example"} feed := &model.Feed{Title: "Example"}
changes.Update(feed) changes.Update(feed)
if feed.Title != "Example" { if feed.Title != "Example" {
t.Fatal(`The Title should not be modified`) t.Error(`The Title should not be modified`)
} }
} }
func TestUpdateFeedUsername(t *testing.T) { func TestUpdateFeedUsername(t *testing.T) {
username := "Alice" username := "Alice"
changes := &feedModification{Username: &username} changes := &feedModificationRequest{Username: &username}
feed := &model.Feed{Username: "Bob"} feed := &model.Feed{Username: "Bob"}
changes.Update(feed) changes.Update(feed)
if feed.Username != username { if feed.Username != username {
t.Fatalf(`Unexpected value, got %q instead of %q`, feed.Username, username) t.Errorf(`Unexpected value, got %q instead of %q`, feed.Username, username)
} }
} }
func TestUpdateFeedUsernameWithEmptyString(t *testing.T) { func TestUpdateFeedUsernameWithEmptyString(t *testing.T) {
username := "" username := ""
changes := &feedModification{Username: &username} changes := &feedModificationRequest{Username: &username}
feed := &model.Feed{Username: "Bob"} feed := &model.Feed{Username: "Bob"}
changes.Update(feed) changes.Update(feed)
if feed.Username != "" { if feed.Username != "" {
t.Fatal(`The Username should be empty now`) t.Error(`The Username should be empty now`)
} }
} }
func TestUpdateFeedUsernameWhenNotSet(t *testing.T) { func TestUpdateFeedUsernameWhenNotSet(t *testing.T) {
changes := &feedModification{} changes := &feedModificationRequest{}
feed := &model.Feed{Username: "Alice"} feed := &model.Feed{Username: "Alice"}
changes.Update(feed) changes.Update(feed)
if feed.Username != "Alice" { if feed.Username != "Alice" {
t.Fatal(`The Username should not be modified`) t.Error(`The Username should not be modified`)
} }
} }
@ -142,16 +142,16 @@ func TestUpdateFeedDisabled(t *testing.T) {
valueTrue := true valueTrue := true
valueFalse := false valueFalse := false
scenarios := []struct { scenarios := []struct {
changes *feedModification changes *feedModificationRequest
feed *model.Feed feed *model.Feed
expected bool expected bool
}{ }{
{&feedModification{}, &model.Feed{Disabled: true}, true}, {&feedModificationRequest{}, &model.Feed{Disabled: true}, true},
{&feedModification{Disabled: &valueTrue}, &model.Feed{Disabled: true}, true}, {&feedModificationRequest{Disabled: &valueTrue}, &model.Feed{Disabled: true}, true},
{&feedModification{Disabled: &valueFalse}, &model.Feed{Disabled: true}, false}, {&feedModificationRequest{Disabled: &valueFalse}, &model.Feed{Disabled: true}, false},
{&feedModification{}, &model.Feed{Disabled: false}, false}, {&feedModificationRequest{}, &model.Feed{Disabled: false}, false},
{&feedModification{Disabled: &valueTrue}, &model.Feed{Disabled: false}, true}, {&feedModificationRequest{Disabled: &valueTrue}, &model.Feed{Disabled: false}, true},
{&feedModification{Disabled: &valueFalse}, &model.Feed{Disabled: false}, false}, {&feedModificationRequest{Disabled: &valueFalse}, &model.Feed{Disabled: false}, false},
} }
for _, scenario := range scenarios { for _, scenario := range scenarios {
@ -167,53 +167,75 @@ func TestUpdateFeedDisabled(t *testing.T) {
func TestUpdateFeedCategory(t *testing.T) { func TestUpdateFeedCategory(t *testing.T) {
categoryID := int64(1) categoryID := int64(1)
changes := &feedModification{CategoryID: &categoryID} changes := &feedModificationRequest{CategoryID: &categoryID}
feed := &model.Feed{Category: &model.Category{ID: 42}} feed := &model.Feed{Category: &model.Category{ID: 42}}
changes.Update(feed) changes.Update(feed)
if feed.Category.ID != categoryID { if feed.Category.ID != categoryID {
t.Fatalf(`Unexpected value, got %q instead of %q`, feed.Username, categoryID) t.Errorf(`Unexpected value, got %q instead of %q`, feed.Username, categoryID)
} }
} }
func TestUpdateFeedCategoryWithZero(t *testing.T) { func TestUpdateFeedCategoryWithZero(t *testing.T) {
categoryID := int64(0) categoryID := int64(0)
changes := &feedModification{CategoryID: &categoryID} changes := &feedModificationRequest{CategoryID: &categoryID}
feed := &model.Feed{Category: &model.Category{ID: 42}} feed := &model.Feed{Category: &model.Category{ID: 42}}
changes.Update(feed) changes.Update(feed)
if feed.Category.ID != 42 { if feed.Category.ID != 42 {
t.Fatal(`The CategoryID should not be modified`) t.Error(`The CategoryID should not be modified`)
} }
} }
func TestUpdateFeedCategoryWhenNotSet(t *testing.T) { func TestUpdateFeedCategoryWhenNotSet(t *testing.T) {
changes := &feedModification{} changes := &feedModificationRequest{}
feed := &model.Feed{Category: &model.Category{ID: 42}} feed := &model.Feed{Category: &model.Category{ID: 42}}
changes.Update(feed) changes.Update(feed)
if feed.Category.ID != 42 { if feed.Category.ID != 42 {
t.Fatal(`The CategoryID should not be modified`) t.Error(`The CategoryID should not be modified`)
}
}
func TestUpdateFeedToIgnoreCache(t *testing.T) {
value := true
changes := &feedModificationRequest{IgnoreHTTPCache: &value}
feed := &model.Feed{IgnoreHTTPCache: false}
changes.Update(feed)
if feed.IgnoreHTTPCache != value {
t.Errorf(`The field IgnoreHTTPCache should be %v`, value)
}
}
func TestUpdateFeedToFetchViaProxy(t *testing.T) {
value := true
changes := &feedModificationRequest{FetchViaProxy: &value}
feed := &model.Feed{FetchViaProxy: false}
changes.Update(feed)
if feed.FetchViaProxy != value {
t.Errorf(`The field FetchViaProxy should be %v`, value)
} }
} }
func TestUpdateUserTheme(t *testing.T) { func TestUpdateUserTheme(t *testing.T) {
theme := "Example 2" theme := "Example 2"
changes := &userModification{Theme: &theme} changes := &userModificationRequest{Theme: &theme}
user := &model.User{Theme: "Example"} user := &model.User{Theme: "Example"}
changes.Update(user) changes.Update(user)
if user.Theme != theme { if user.Theme != theme {
t.Fatalf(`Unexpected value, got %q instead of %q`, user.Theme, theme) t.Errorf(`Unexpected value, got %q instead of %q`, user.Theme, theme)
} }
} }
func TestUserThemeWhenNotSet(t *testing.T) { func TestUserThemeWhenNotSet(t *testing.T) {
changes := &userModification{} changes := &userModificationRequest{}
user := &model.User{Theme: "Example"} user := &model.User{Theme: "Example"}
changes.Update(user) changes.Update(user)
if user.Theme != "Example" { if user.Theme != "Example" {
t.Fatal(`The user Theme should not be modified`) t.Error(`The user Theme should not be modified`)
} }
} }

View file

@ -12,18 +12,18 @@ import (
) )
func (h *handler) getSubscriptions(w http.ResponseWriter, r *http.Request) { func (h *handler) getSubscriptions(w http.ResponseWriter, r *http.Request) {
subscriptionInfo, bodyErr := decodeURLPayload(r.Body) subscriptionRequest, bodyErr := decodeSubscriptionDiscoveryRequest(r.Body)
if bodyErr != nil { if bodyErr != nil {
json.BadRequest(w, r, bodyErr) json.BadRequest(w, r, bodyErr)
return return
} }
subscriptions, finderErr := subscription.FindSubscriptions( subscriptions, finderErr := subscription.FindSubscriptions(
subscriptionInfo.URL, subscriptionRequest.URL,
subscriptionInfo.UserAgent, subscriptionRequest.UserAgent,
subscriptionInfo.Username, subscriptionRequest.Username,
subscriptionInfo.Password, subscriptionRequest.Password,
subscriptionInfo.FetchViaProxy, subscriptionRequest.FetchViaProxy,
) )
if finderErr != nil { if finderErr != nil {
json.ServerError(w, r, finderErr) json.ServerError(w, r, finderErr)

View file

@ -28,7 +28,7 @@ func (h *handler) createUser(w http.ResponseWriter, r *http.Request) {
return return
} }
user, err := decodeUserCreationPayload(r.Body) user, err := decodeUserCreationRequest(r.Body)
if err != nil { if err != nil {
json.BadRequest(w, r, err) json.BadRequest(w, r, err)
return return
@ -61,7 +61,7 @@ func (h *handler) updateUser(w http.ResponseWriter, r *http.Request) {
} }
userID := request.RouteInt64Param(r, "userID") userID := request.RouteInt64Param(r, "userID")
userChanges, err := decodeUserModificationPayload(r.Body) userChanges, err := decodeUserModificationRequest(r.Body)
if err != nil { if err != nil {
json.BadRequest(w, r, err) json.BadRequest(w, r, err)
return return

View file

@ -115,6 +115,9 @@ type FeedModification struct {
Username *string `json:"username"` Username *string `json:"username"`
Password *string `json:"password"` Password *string `json:"password"`
CategoryID *int64 `json:"category_id"` CategoryID *int64 `json:"category_id"`
Disabled *bool `json:"disabled"`
IgnoreHTTPCache *bool `json:"ignore_http_cache"`
FetchViaProxy *bool `json:"fetch_via_proxy"`
} }
// FeedIcon represents the feed icon. // FeedIcon represents the feed icon.

1
go.mod
View file

@ -11,6 +11,7 @@ require (
github.com/prometheus/client_golang v1.8.0 github.com/prometheus/client_golang v1.8.0
github.com/rylans/getlang v0.0.0-20200505200108-4c3188ff8a2d github.com/rylans/getlang v0.0.0-20200505200108-4c3188ff8a2d
github.com/stretchr/testify v1.6.1 // indirect github.com/stretchr/testify v1.6.1 // indirect
github.com/tdewolff/minify/v2 v2.9.10 // indirect
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/net v0.0.0-20201029221708-28c70e62bb1d golang.org/x/net v0.0.0-20201029221708-28c70e62bb1d
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d

14
go.sum
View file

@ -34,6 +34,7 @@ github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QH
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U=
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
@ -51,6 +52,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
@ -62,6 +64,7 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
@ -166,6 +169,7 @@ github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
@ -272,6 +276,7 @@ github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4k
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
@ -282,6 +287,13 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tdewolff/minify v1.1.0 h1:nxHQi1ML+g3ZbZHffiZ6eC7vMqNvSRfX3KB5Y5y/kfw=
github.com/tdewolff/minify v2.3.6+incompatible h1:2hw5/9ZvxhWLvBUnHE06gElGYz+Jv9R4Eys0XUzItYo=
github.com/tdewolff/minify/v2 v2.9.10 h1:p+ifTTl+JMFFLDYNAm7nxQ9XuCG10HTW00wlPAZ7aoE=
github.com/tdewolff/minify/v2 v2.9.10/go.mod h1:U1Nc+/YBSB0FPEarqcgkYH3Ep4DNyyIbOyl5P4eWMuo=
github.com/tdewolff/parse/v2 v2.5.5 h1:b7ICJa4I/54JQGEGgTte8DiyJPKcC5g8V773QMzkeUM=
github.com/tdewolff/parse/v2 v2.5.5/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho=
github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
@ -360,11 +372,13 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200724161237-0e2f3a69832c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211 h1:9UQO31fZ+0aKQOFldThf7BKPMJTiBfWycGh/u3UoO88= golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211 h1:9UQO31fZ+0aKQOFldThf7BKPMJTiBfWycGh/u3UoO88=
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=