mirror of
https://github.com/miniflux/v2.git
synced 2025-08-01 17:38:37 +00:00
Use struct embedding to reduce code duplication
This commit is contained in:
parent
e2ee74428a
commit
8e28e41b02
2 changed files with 21 additions and 37 deletions
|
@ -159,25 +159,7 @@ type FeedCreationRequestFromSubscriptionDiscovery struct {
|
||||||
ETag string
|
ETag string
|
||||||
LastModified string
|
LastModified string
|
||||||
|
|
||||||
FeedURL string `json:"feed_url"`
|
FeedCreationRequest
|
||||||
CategoryID int64 `json:"category_id"`
|
|
||||||
UserAgent string `json:"user_agent"`
|
|
||||||
Cookie string `json:"cookie"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
Password string `json:"password"`
|
|
||||||
Crawler bool `json:"crawler"`
|
|
||||||
Disabled bool `json:"disabled"`
|
|
||||||
NoMediaPlayer bool `json:"no_media_player"`
|
|
||||||
IgnoreHTTPCache bool `json:"ignore_http_cache"`
|
|
||||||
AllowSelfSignedCertificates bool `json:"allow_self_signed_certificates"`
|
|
||||||
FetchViaProxy bool `json:"fetch_via_proxy"`
|
|
||||||
ScraperRules string `json:"scraper_rules"`
|
|
||||||
RewriteRules string `json:"rewrite_rules"`
|
|
||||||
BlocklistRules string `json:"blocklist_rules"`
|
|
||||||
KeeplistRules string `json:"keeplist_rules"`
|
|
||||||
HideGlobally bool `json:"hide_globally"`
|
|
||||||
UrlRewriteRules string `json:"urlrewrite_rules"`
|
|
||||||
DisableHTTP2 bool `json:"disable_http2"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FeedModificationRequest represents the request to update a feed.
|
// FeedModificationRequest represents the request to update a feed.
|
||||||
|
|
|
@ -86,24 +86,26 @@ func (h *handler) submitSubscription(w http.ResponseWriter, r *http.Request) {
|
||||||
html.OK(w, r, v.Render("add_subscription"))
|
html.OK(w, r, v.Render("add_subscription"))
|
||||||
case n == 1 && subscriptionFinder.IsFeedAlreadyDownloaded():
|
case n == 1 && subscriptionFinder.IsFeedAlreadyDownloaded():
|
||||||
feed, localizedError := feedHandler.CreateFeedFromSubscriptionDiscovery(h.store, user.ID, &model.FeedCreationRequestFromSubscriptionDiscovery{
|
feed, localizedError := feedHandler.CreateFeedFromSubscriptionDiscovery(h.store, user.ID, &model.FeedCreationRequestFromSubscriptionDiscovery{
|
||||||
Content: subscriptionFinder.FeedResponseInfo().Content,
|
Content: subscriptionFinder.FeedResponseInfo().Content,
|
||||||
ETag: subscriptionFinder.FeedResponseInfo().ETag,
|
ETag: subscriptionFinder.FeedResponseInfo().ETag,
|
||||||
LastModified: subscriptionFinder.FeedResponseInfo().LastModified,
|
LastModified: subscriptionFinder.FeedResponseInfo().LastModified,
|
||||||
CategoryID: subscriptionForm.CategoryID,
|
FeedCreationRequest: model.FeedCreationRequest{
|
||||||
FeedURL: subscriptions[0].URL,
|
CategoryID: subscriptionForm.CategoryID,
|
||||||
Crawler: subscriptionForm.Crawler,
|
FeedURL: subscriptions[0].URL,
|
||||||
AllowSelfSignedCertificates: subscriptionForm.AllowSelfSignedCertificates,
|
AllowSelfSignedCertificates: subscriptionForm.AllowSelfSignedCertificates,
|
||||||
UserAgent: subscriptionForm.UserAgent,
|
Crawler: subscriptionForm.Crawler,
|
||||||
Cookie: subscriptionForm.Cookie,
|
UserAgent: subscriptionForm.UserAgent,
|
||||||
Username: subscriptionForm.Username,
|
Cookie: subscriptionForm.Cookie,
|
||||||
Password: subscriptionForm.Password,
|
Username: subscriptionForm.Username,
|
||||||
ScraperRules: subscriptionForm.ScraperRules,
|
Password: subscriptionForm.Password,
|
||||||
RewriteRules: subscriptionForm.RewriteRules,
|
ScraperRules: subscriptionForm.ScraperRules,
|
||||||
BlocklistRules: subscriptionForm.BlocklistRules,
|
RewriteRules: subscriptionForm.RewriteRules,
|
||||||
KeeplistRules: subscriptionForm.KeeplistRules,
|
BlocklistRules: subscriptionForm.BlocklistRules,
|
||||||
UrlRewriteRules: subscriptionForm.UrlRewriteRules,
|
KeeplistRules: subscriptionForm.KeeplistRules,
|
||||||
FetchViaProxy: subscriptionForm.FetchViaProxy,
|
UrlRewriteRules: subscriptionForm.UrlRewriteRules,
|
||||||
DisableHTTP2: subscriptionForm.DisableHTTP2,
|
FetchViaProxy: subscriptionForm.FetchViaProxy,
|
||||||
|
DisableHTTP2: subscriptionForm.DisableHTTP2,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
if localizedError != nil {
|
if localizedError != nil {
|
||||||
v.Set("form", subscriptionForm)
|
v.Set("form", subscriptionForm)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue