Add option to hide feeds from the global Unread list

This commit is contained in:
Jan-Lukas Else 2021-08-15 17:32:43 +02:00 committed by fguillot
parent 8bc06a5d65
commit 9965abccfb
23 changed files with 49 additions and 5 deletions

View file

@ -126,6 +126,7 @@ type Feed struct {
Username string `json:"username"` Username string `json:"username"`
Password string `json:"password"` Password string `json:"password"`
Category *Category `json:"category,omitempty"` Category *Category `json:"category,omitempty"`
HideGlobally bool `json:"hide_globally"`
} }
// FeedCreationRequest represents the request to create a feed. // FeedCreationRequest represents the request to create a feed.
@ -145,6 +146,7 @@ type FeedCreationRequest struct {
RewriteRules string `json:"rewrite_rules"` RewriteRules string `json:"rewrite_rules"`
BlocklistRules string `json:"blocklist_rules"` BlocklistRules string `json:"blocklist_rules"`
KeeplistRules string `json:"keeplist_rules"` KeeplistRules string `json:"keeplist_rules"`
HideGlobally bool `json:"hide_globally"`
} }
// FeedModificationRequest represents the request to update a feed. // FeedModificationRequest represents the request to update a feed.
@ -166,6 +168,7 @@ type FeedModificationRequest struct {
IgnoreHTTPCache *bool `json:"ignore_http_cache"` IgnoreHTTPCache *bool `json:"ignore_http_cache"`
AllowSelfSignedCertificates *bool `json:"allow_self_signed_certificates"` AllowSelfSignedCertificates *bool `json:"allow_self_signed_certificates"`
FetchViaProxy *bool `json:"fetch_via_proxy"` FetchViaProxy *bool `json:"fetch_via_proxy"`
HideGlobally *bool `json:"hide_globally"`
} }
// FeedIcon represents the feed icon. // FeedIcon represents the feed icon.

View file

@ -540,4 +540,10 @@ var migrations = []func(tx *sql.Tx) error{
`) `)
return err return err
}, },
func(tx *sql.Tx) (err error) {
_, err = tx.Exec(`
ALTER TABLE feeds ADD COLUMN hide_globally boolean not null default false
`)
return err
},
} }

View file

@ -276,6 +276,7 @@
"form.feed.label.allow_self_signed_certificates": "Erlaube selbstsignierte oder ungültige Zertifikate", "form.feed.label.allow_self_signed_certificates": "Erlaube selbstsignierte oder ungültige Zertifikate",
"form.feed.label.fetch_via_proxy": "Über Proxy abrufen", "form.feed.label.fetch_via_proxy": "Über Proxy abrufen",
"form.feed.label.disabled": "Dieses Abonnement nicht aktualisieren", "form.feed.label.disabled": "Dieses Abonnement nicht aktualisieren",
"form.feed.label.hide_globally": "Einträge in der globalen Ungelesen-Liste ausblenden",
"form.category.label.title": "Titel", "form.category.label.title": "Titel",
"form.category.hide_globally": "Einträge in der globalen Ungelesen-Liste ausblenden", "form.category.hide_globally": "Einträge in der globalen Ungelesen-Liste ausblenden",
"form.user.label.username": "Benutzername", "form.user.label.username": "Benutzername",

View file

@ -276,6 +276,7 @@
"form.feed.label.allow_self_signed_certificates": "Να επιτρέπονται αυτο-υπογεγραμμένα ή μη έγκυρα πιστοποιητικά", "form.feed.label.allow_self_signed_certificates": "Να επιτρέπονται αυτο-υπογεγραμμένα ή μη έγκυρα πιστοποιητικά",
"form.feed.label.fetch_via_proxy": "Λήψη μέσω διακομιστή μεσολάβησης", "form.feed.label.fetch_via_proxy": "Λήψη μέσω διακομιστή μεσολάβησης",
"form.feed.label.disabled": "Μη ανανέωση αυτής της ροής", "form.feed.label.disabled": "Μη ανανέωση αυτής της ροής",
"form.feed.label.hide_globally": "Απόκρυψη καταχωρήσεων σε γενική λίστα μη αναγνωσμένων",
"form.category.label.title": "Τίτλος", "form.category.label.title": "Τίτλος",
"form.category.hide_globally": "Απόκρυψη καταχωρήσεων σε γενική λίστα μη αναγνωσμένων", "form.category.hide_globally": "Απόκρυψη καταχωρήσεων σε γενική λίστα μη αναγνωσμένων",
"form.user.label.username": "Χρήστης", "form.user.label.username": "Χρήστης",

View file

@ -276,6 +276,7 @@
"form.feed.label.allow_self_signed_certificates": "Allow self-signed or invalid certificates", "form.feed.label.allow_self_signed_certificates": "Allow self-signed or invalid certificates",
"form.feed.label.fetch_via_proxy": "Fetch via proxy", "form.feed.label.fetch_via_proxy": "Fetch via proxy",
"form.feed.label.disabled": "Do not refresh this feed", "form.feed.label.disabled": "Do not refresh this feed",
"form.feed.label.hide_globally": "Hide entries in global unread list",
"form.category.label.title": "Title", "form.category.label.title": "Title",
"form.category.hide_globally": "Hide entries in global unread list", "form.category.hide_globally": "Hide entries in global unread list",
"form.user.label.username": "Username", "form.user.label.username": "Username",

View file

@ -276,6 +276,7 @@
"form.feed.label.allow_self_signed_certificates": "Permitir certificados autofirmados o no válidos", "form.feed.label.allow_self_signed_certificates": "Permitir certificados autofirmados o no válidos",
"form.feed.label.fetch_via_proxy": "Buscar a través de proxy", "form.feed.label.fetch_via_proxy": "Buscar a través de proxy",
"form.feed.label.disabled": "No actualice este feed", "form.feed.label.disabled": "No actualice este feed",
"form.feed.label.hide_globally": "Ocultar entradas en la lista global de no leídos",
"form.category.label.title": "Título", "form.category.label.title": "Título",
"form.category.hide_globally": "Ocultar entradas en la lista global de no leídos", "form.category.hide_globally": "Ocultar entradas en la lista global de no leídos",
"form.user.label.username": "Nombre de usuario", "form.user.label.username": "Nombre de usuario",

View file

@ -276,6 +276,7 @@
"form.feed.label.allow_self_signed_certificates": "Autoriser les certificats auto-signés ou non valides", "form.feed.label.allow_self_signed_certificates": "Autoriser les certificats auto-signés ou non valides",
"form.feed.label.fetch_via_proxy": "Récupérer via proxy", "form.feed.label.fetch_via_proxy": "Récupérer via proxy",
"form.feed.label.disabled": "Ne pas actualiser ce flux", "form.feed.label.disabled": "Ne pas actualiser ce flux",
"form.feed.label.hide_globally": "Masquer les entrées dans la liste globale non lue",
"form.category.label.title": "Titre", "form.category.label.title": "Titre",
"form.category.hide_globally": "Masquer les entrées dans la liste globale non lue", "form.category.hide_globally": "Masquer les entrées dans la liste globale non lue",
"form.user.label.username": "Nom d'utilisateur", "form.user.label.username": "Nom d'utilisateur",

View file

@ -276,6 +276,7 @@
"form.feed.label.allow_self_signed_certificates": "Consenti certificati autofirmati o non validi", "form.feed.label.allow_self_signed_certificates": "Consenti certificati autofirmati o non validi",
"form.feed.label.fetch_via_proxy": "Recuperare tramite proxy", "form.feed.label.fetch_via_proxy": "Recuperare tramite proxy",
"form.feed.label.disabled": "Non aggiornare questo feed", "form.feed.label.disabled": "Non aggiornare questo feed",
"form.feed.label.hide_globally": "Nascondere le voci nella lista globale dei non letti",
"form.category.label.title": "Titolo", "form.category.label.title": "Titolo",
"form.category.hide_globally": "Nascondere le voci nella lista globale dei non letti", "form.category.hide_globally": "Nascondere le voci nella lista globale dei non letti",
"form.user.label.username": "Nome utente", "form.user.label.username": "Nome utente",

View file

@ -276,6 +276,7 @@
"form.feed.label.allow_self_signed_certificates": "自己署名証明書または無効な証明書を許可する", "form.feed.label.allow_self_signed_certificates": "自己署名証明書または無効な証明書を許可する",
"form.feed.label.fetch_via_proxy": "プロキシ経由でフェッチ", "form.feed.label.fetch_via_proxy": "プロキシ経由でフェッチ",
"form.feed.label.disabled": "このフィードを更新しない", "form.feed.label.disabled": "このフィードを更新しない",
"form.feed.label.hide_globally": "グローバル未読リストのエントリーを隠す",
"form.category.label.title": "タイトル", "form.category.label.title": "タイトル",
"form.category.hide_globally": "グローバル未読リストのエントリーを隠す", "form.category.hide_globally": "グローバル未読リストのエントリーを隠す",
"form.user.label.username": "ユーザー名", "form.user.label.username": "ユーザー名",

View file

@ -276,6 +276,7 @@
"form.feed.label.allow_self_signed_certificates": "Sta zelfondertekende of ongeldige certificaten toe", "form.feed.label.allow_self_signed_certificates": "Sta zelfondertekende of ongeldige certificaten toe",
"form.feed.label.fetch_via_proxy": "Ophalen via proxy", "form.feed.label.fetch_via_proxy": "Ophalen via proxy",
"form.feed.label.disabled": "Vernieuw deze feed niet", "form.feed.label.disabled": "Vernieuw deze feed niet",
"form.feed.label.hide_globally": "Verberg items in de globale ongelezen lijst",
"form.category.label.title": "Naam", "form.category.label.title": "Naam",
"form.category.hide_globally": "Verberg items in de globale ongelezen lijst", "form.category.hide_globally": "Verberg items in de globale ongelezen lijst",
"form.user.label.username": "Gebruikersnaam", "form.user.label.username": "Gebruikersnaam",

View file

@ -278,6 +278,7 @@
"form.feed.label.allow_self_signed_certificates": "Zezwalaj na certyfikaty z podpisem własnym lub nieprawidłowe certyfikaty", "form.feed.label.allow_self_signed_certificates": "Zezwalaj na certyfikaty z podpisem własnym lub nieprawidłowe certyfikaty",
"form.feed.label.fetch_via_proxy": "Pobierz przez proxy", "form.feed.label.fetch_via_proxy": "Pobierz przez proxy",
"form.feed.label.disabled": "Не обновлять этот канал", "form.feed.label.disabled": "Не обновлять этот канал",
"form.feed.label.hide_globally": "Ukryj wpisy na globalnej liście nieprzeczytanych",
"form.category.label.title": "Tytuł", "form.category.label.title": "Tytuł",
"form.category.hide_globally": "Ukryj wpisy na globalnej liście nieprzeczytanych", "form.category.hide_globally": "Ukryj wpisy na globalnej liście nieprzeczytanych",
"form.user.label.username": "Nazwa użytkownika", "form.user.label.username": "Nazwa użytkownika",

View file

@ -276,6 +276,7 @@
"form.feed.label.allow_self_signed_certificates": "Permitir certificados autoassinados ou inválidos", "form.feed.label.allow_self_signed_certificates": "Permitir certificados autoassinados ou inválidos",
"form.feed.label.disabled": "Não atualizar esta fonte", "form.feed.label.disabled": "Não atualizar esta fonte",
"form.feed.label.fetch_via_proxy": "Buscar via proxy", "form.feed.label.fetch_via_proxy": "Buscar via proxy",
"form.feed.label.hide_globally": "Ocultar entradas na lista global não lida",
"form.category.label.title": "Título", "form.category.label.title": "Título",
"form.category.hide_globally": "Ocultar entradas na lista global não lida", "form.category.hide_globally": "Ocultar entradas na lista global não lida",
"form.user.label.username": "Nome de usuário", "form.user.label.username": "Nome de usuário",

View file

@ -278,6 +278,7 @@
"form.feed.label.allow_self_signed_certificates": "Разрешить самоподписанные или недействительные сертификаты", "form.feed.label.allow_self_signed_certificates": "Разрешить самоподписанные или недействительные сертификаты",
"form.feed.label.fetch_via_proxy": "Получить через прокси", "form.feed.label.fetch_via_proxy": "Получить через прокси",
"form.feed.label.disabled": "Не обновлять этот канал", "form.feed.label.disabled": "Не обновлять этот канал",
"form.feed.label.hide_globally": "Скрыть записи в глобальном списке непрочитанных",
"form.category.label.title": "Название", "form.category.label.title": "Название",
"form.category.hide_globally": "Скрыть записи в глобальном списке непрочитанных", "form.category.hide_globally": "Скрыть записи в глобальном списке непрочитанных",
"form.user.label.username": "Имя пользователя", "form.user.label.username": "Имя пользователя",

View file

@ -276,6 +276,7 @@
"form.feed.label.allow_self_signed_certificates": "Kendinden imzalı veya geçersiz sertifikalara izin ver", "form.feed.label.allow_self_signed_certificates": "Kendinden imzalı veya geçersiz sertifikalara izin ver",
"form.feed.label.fetch_via_proxy": "Proxy ile çek", "form.feed.label.fetch_via_proxy": "Proxy ile çek",
"form.feed.label.disabled": "Bu beslemeyi yenileme", "form.feed.label.disabled": "Bu beslemeyi yenileme",
"form.feed.label.hide_globally": "Genel okunmamış listesindeki girişleri gizle",
"form.category.label.title": "Başlık", "form.category.label.title": "Başlık",
"form.category.hide_globally": "Genel okunmamış listesindeki girişleri gizle", "form.category.hide_globally": "Genel okunmamış listesindeki girişleri gizle",
"form.user.label.username": "Kullanıcı Adı", "form.user.label.username": "Kullanıcı Adı",

View file

@ -274,6 +274,7 @@
"form.feed.label.allow_self_signed_certificates": "允许自签名或无效的证书", "form.feed.label.allow_self_signed_certificates": "允许自签名或无效的证书",
"form.feed.label.fetch_via_proxy": "通过代理获取", "form.feed.label.fetch_via_proxy": "通过代理获取",
"form.feed.label.disabled": "请勿刷新此Feed", "form.feed.label.disabled": "请勿刷新此Feed",
"form.feed.label.hide_globally": "隐藏全局未读列表中的条目",
"form.category.label.title": "标题", "form.category.label.title": "标题",
"form.category.hide_globally": "隐藏全局未读列表中的条目", "form.category.hide_globally": "隐藏全局未读列表中的条目",
"form.user.label.username": "用户名", "form.user.label.username": "用户名",

View file

@ -51,6 +51,7 @@ type Feed struct {
Category *Category `json:"category,omitempty"` Category *Category `json:"category,omitempty"`
Entries Entries `json:"entries,omitempty"` Entries Entries `json:"entries,omitempty"`
Icon *FeedIcon `json:"icon"` Icon *FeedIcon `json:"icon"`
HideGlobally bool `json:"hide_globally"`
UnreadCount int `json:"-"` UnreadCount int `json:"-"`
ReadCount int `json:"-"` ReadCount int `json:"-"`
} }
@ -134,6 +135,7 @@ type FeedCreationRequest struct {
RewriteRules string `json:"rewrite_rules"` RewriteRules string `json:"rewrite_rules"`
BlocklistRules string `json:"blocklist_rules"` BlocklistRules string `json:"blocklist_rules"`
KeeplistRules string `json:"keeplist_rules"` KeeplistRules string `json:"keeplist_rules"`
HideGlobally bool `json:"hide_globally"`
} }
// FeedModificationRequest represents the request to update a feed. // FeedModificationRequest represents the request to update a feed.
@ -155,6 +157,7 @@ type FeedModificationRequest struct {
IgnoreHTTPCache *bool `json:"ignore_http_cache"` IgnoreHTTPCache *bool `json:"ignore_http_cache"`
AllowSelfSignedCertificates *bool `json:"allow_self_signed_certificates"` AllowSelfSignedCertificates *bool `json:"allow_self_signed_certificates"`
FetchViaProxy *bool `json:"fetch_via_proxy"` FetchViaProxy *bool `json:"fetch_via_proxy"`
HideGlobally *bool `json:"hide_globally"`
} }
// Patch updates a feed with modified values. // Patch updates a feed with modified values.
@ -226,6 +229,10 @@ func (f *FeedModificationRequest) Patch(feed *Feed) {
if f.FetchViaProxy != nil { if f.FetchViaProxy != nil {
feed.FetchViaProxy = *f.FetchViaProxy feed.FetchViaProxy = *f.FetchViaProxy
} }
if f.HideGlobally != nil {
feed.HideGlobally = *f.HideGlobally
}
} }
// Feeds is a list of feed // Feeds is a list of feed

View file

@ -357,7 +357,10 @@ func (s *Storage) SetEntriesStatusCount(userID int64, entryIDs []int64, status s
FROM entries e FROM entries e
JOIN feeds f ON (f.id = e.feed_id) JOIN feeds f ON (f.id = e.feed_id)
JOIN categories c ON (c.id = f.category_id) JOIN categories c ON (c.id = f.category_id)
WHERE e.user_id = $1 AND e.id = ANY($2) AND NOT c.hide_globally WHERE e.user_id = $1
AND e.id = ANY($2)
AND NOT f.hide_globally
AND NOT c.hide_globally
` `
row := s.db.QueryRow(query, userID, pq.Array(entryIDs)) row := s.db.QueryRow(query, userID, pq.Array(entryIDs))
visible := 0 visible := 0

View file

@ -183,6 +183,7 @@ func (e *EntryQueryBuilder) WithOffset(offset int) *EntryQueryBuilder {
func (e *EntryQueryBuilder) WithGloballyVisible() *EntryQueryBuilder { func (e *EntryQueryBuilder) WithGloballyVisible() *EntryQueryBuilder {
e.conditions = append(e.conditions, "not c.hide_globally") e.conditions = append(e.conditions, "not c.hide_globally")
e.conditions = append(e.conditions, "not f.hide_globally")
return e return e
} }

View file

@ -233,10 +233,11 @@ func (s *Storage) CreateFeed(feed *model.Feed) error {
keeplist_rules, keeplist_rules,
ignore_http_cache, ignore_http_cache,
allow_self_signed_certificates, allow_self_signed_certificates,
fetch_via_proxy fetch_via_proxy,
hide_globally
) )
VALUES VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20) ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21)
RETURNING RETURNING
id id
` `
@ -262,6 +263,7 @@ func (s *Storage) CreateFeed(feed *model.Feed) error {
feed.IgnoreHTTPCache, feed.IgnoreHTTPCache,
feed.AllowSelfSignedCertificates, feed.AllowSelfSignedCertificates,
feed.FetchViaProxy, feed.FetchViaProxy,
feed.HideGlobally,
).Scan(&feed.ID) ).Scan(&feed.ID)
if err != nil { if err != nil {
return fmt.Errorf(`store: unable to create feed %q: %v`, feed.FeedURL, err) return fmt.Errorf(`store: unable to create feed %q: %v`, feed.FeedURL, err)
@ -319,9 +321,10 @@ func (s *Storage) UpdateFeed(feed *model.Feed) (err error) {
next_check_at=$20, next_check_at=$20,
ignore_http_cache=$21, ignore_http_cache=$21,
allow_self_signed_certificates=$22, allow_self_signed_certificates=$22,
fetch_via_proxy=$23 fetch_via_proxy=$23,
hide_globally=$24
WHERE WHERE
id=$24 AND user_id=$25 id=$25 AND user_id=$26
` `
_, err = s.db.Exec(query, _, err = s.db.Exec(query,
feed.FeedURL, feed.FeedURL,
@ -347,6 +350,7 @@ func (s *Storage) UpdateFeed(feed *model.Feed) (err error) {
feed.IgnoreHTTPCache, feed.IgnoreHTTPCache,
feed.AllowSelfSignedCertificates, feed.AllowSelfSignedCertificates,
feed.FetchViaProxy, feed.FetchViaProxy,
feed.HideGlobally,
feed.ID, feed.ID,
feed.UserID, feed.UserID,
) )

View file

@ -166,6 +166,7 @@ func (f *FeedQueryBuilder) GetFeeds() (model.Feeds, error) {
f.allow_self_signed_certificates, f.allow_self_signed_certificates,
f.fetch_via_proxy, f.fetch_via_proxy,
f.disabled, f.disabled,
f.hide_globally,
f.category_id, f.category_id,
c.title as category_title, c.title as category_title,
fi.icon_id, fi.icon_id,
@ -226,6 +227,7 @@ func (f *FeedQueryBuilder) GetFeeds() (model.Feeds, error) {
&feed.AllowSelfSignedCertificates, &feed.AllowSelfSignedCertificates,
&feed.FetchViaProxy, &feed.FetchViaProxy,
&feed.Disabled, &feed.Disabled,
&feed.HideGlobally,
&feed.Category.ID, &feed.Category.ID,
&feed.Category.Title, &feed.Category.Title,
&iconID, &iconID,

View file

@ -87,6 +87,7 @@
<label><input type="checkbox" name="fetch_via_proxy" value="1" {{ if .form.FetchViaProxy }}checked{{ end }}> {{ t "form.feed.label.fetch_via_proxy" }}</label> <label><input type="checkbox" name="fetch_via_proxy" value="1" {{ if .form.FetchViaProxy }}checked{{ end }}> {{ t "form.feed.label.fetch_via_proxy" }}</label>
{{ end }} {{ end }}
<label><input type="checkbox" name="disabled" value="1" {{ if .form.Disabled }}checked{{ end }}> {{ t "form.feed.label.disabled" }}</label> <label><input type="checkbox" name="disabled" value="1" {{ if .form.Disabled }}checked{{ end }}> {{ t "form.feed.label.disabled" }}</label>
<label><input type="checkbox" name="hide_globally" value="1" {{ if .form.HideGlobally }}checked{{ end }}> {{ t "form.feed.label.hide_globally" }}</label>
<div class="buttons"> <div class="buttons">
<button type="submit" class="button button-primary" data-label-loading="{{ t "form.submit.saving" }}">{{ t "action.update" }}</button> {{ t "action.or" }} <a href="{{ route "feeds" }}">{{ t "action.cancel" }}</a> <button type="submit" class="button button-primary" data-label-loading="{{ t "form.submit.saving" }}">{{ t "action.update" }}</button> {{ t "action.or" }} <a href="{{ route "feeds" }}">{{ t "action.cancel" }}</a>

View file

@ -58,6 +58,7 @@ func (h *handler) showEditFeedPage(w http.ResponseWriter, r *http.Request) {
AllowSelfSignedCertificates: feed.AllowSelfSignedCertificates, AllowSelfSignedCertificates: feed.AllowSelfSignedCertificates,
FetchViaProxy: feed.FetchViaProxy, FetchViaProxy: feed.FetchViaProxy,
Disabled: feed.Disabled, Disabled: feed.Disabled,
HideGlobally: feed.HideGlobally,
} }
sess := session.New(h.store, request.SessionID(r)) sess := session.New(h.store, request.SessionID(r))

View file

@ -30,6 +30,7 @@ type FeedForm struct {
AllowSelfSignedCertificates bool AllowSelfSignedCertificates bool
FetchViaProxy bool FetchViaProxy bool
Disabled bool Disabled bool
HideGlobally bool
} }
// Merge updates the fields of the given feed. // Merge updates the fields of the given feed.
@ -53,6 +54,7 @@ func (f FeedForm) Merge(feed *model.Feed) *model.Feed {
feed.AllowSelfSignedCertificates = f.AllowSelfSignedCertificates feed.AllowSelfSignedCertificates = f.AllowSelfSignedCertificates
feed.FetchViaProxy = f.FetchViaProxy feed.FetchViaProxy = f.FetchViaProxy
feed.Disabled = f.Disabled feed.Disabled = f.Disabled
feed.HideGlobally = f.HideGlobally
return feed return feed
} }
@ -80,5 +82,6 @@ func NewFeedForm(r *http.Request) *FeedForm {
AllowSelfSignedCertificates: r.FormValue("allow_self_signed_certificates") == "1", AllowSelfSignedCertificates: r.FormValue("allow_self_signed_certificates") == "1",
FetchViaProxy: r.FormValue("fetch_via_proxy") == "1", FetchViaProxy: r.FormValue("fetch_via_proxy") == "1",
Disabled: r.FormValue("disabled") == "1", Disabled: r.FormValue("disabled") == "1",
HideGlobally: r.FormValue("hide_globally") == "1",
} }
} }