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

View File

@ -540,4 +540,10 @@ var migrations = []func(tx *sql.Tx) error{
`)
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.fetch_via_proxy": "Über Proxy abrufen",
"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.hide_globally": "Einträge in der globalen Ungelesen-Liste ausblenden",
"form.user.label.username": "Benutzername",

View File

@ -276,6 +276,7 @@
"form.feed.label.allow_self_signed_certificates": "Να επιτρέπονται αυτο-υπογεγραμμένα ή μη έγκυρα πιστοποιητικά",
"form.feed.label.fetch_via_proxy": "Λήψη μέσω διακομιστή μεσολάβησης",
"form.feed.label.disabled": "Μη ανανέωση αυτής της ροής",
"form.feed.label.hide_globally": "Απόκρυψη καταχωρήσεων σε γενική λίστα μη αναγνωσμένων",
"form.category.label.title": "Τίτλος",
"form.category.hide_globally": "Απόκρυψη καταχωρήσεων σε γενική λίστα μη αναγνωσμένων",
"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.fetch_via_proxy": "Fetch via proxy",
"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.hide_globally": "Hide entries in global unread list",
"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.fetch_via_proxy": "Buscar a través de proxy",
"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.hide_globally": "Ocultar entradas en la lista global de no leídos",
"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.fetch_via_proxy": "Récupérer via proxy",
"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.hide_globally": "Masquer les entrées dans la liste globale non lue",
"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.fetch_via_proxy": "Recuperare tramite proxy",
"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.hide_globally": "Nascondere le voci nella lista globale dei non letti",
"form.user.label.username": "Nome utente",

View File

@ -276,6 +276,7 @@
"form.feed.label.allow_self_signed_certificates": "自己署名証明書または無効な証明書を許可する",
"form.feed.label.fetch_via_proxy": "プロキシ経由でフェッチ",
"form.feed.label.disabled": "このフィードを更新しない",
"form.feed.label.hide_globally": "グローバル未読リストのエントリーを隠す",
"form.category.label.title": "タイトル",
"form.category.hide_globally": "グローバル未読リストのエントリーを隠す",
"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.fetch_via_proxy": "Ophalen via proxy",
"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.hide_globally": "Verberg items in de globale ongelezen lijst",
"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.fetch_via_proxy": "Pobierz przez proxy",
"form.feed.label.disabled": "Не обновлять этот канал",
"form.feed.label.hide_globally": "Ukryj wpisy na globalnej liście nieprzeczytanych",
"form.category.label.title": "Tytuł",
"form.category.hide_globally": "Ukryj wpisy na globalnej liście nieprzeczytanych",
"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.disabled": "Não atualizar esta fonte",
"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.hide_globally": "Ocultar entradas na lista global não lida",
"form.user.label.username": "Nome de usuário",

View File

@ -278,6 +278,7 @@
"form.feed.label.allow_self_signed_certificates": "Разрешить самоподписанные или недействительные сертификаты",
"form.feed.label.fetch_via_proxy": "Получить через прокси",
"form.feed.label.disabled": "Не обновлять этот канал",
"form.feed.label.hide_globally": "Скрыть записи в глобальном списке непрочитанных",
"form.category.label.title": "Название",
"form.category.hide_globally": "Скрыть записи в глобальном списке непрочитанных",
"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.fetch_via_proxy": "Proxy ile çek",
"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.hide_globally": "Genel okunmamış listesindeki girişleri gizle",
"form.user.label.username": "Kullanıcı Adı",

View File

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

View File

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

View File

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

View File

@ -233,10 +233,11 @@ func (s *Storage) CreateFeed(feed *model.Feed) error {
keeplist_rules,
ignore_http_cache,
allow_self_signed_certificates,
fetch_via_proxy
fetch_via_proxy,
hide_globally
)
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
id
`
@ -262,6 +263,7 @@ func (s *Storage) CreateFeed(feed *model.Feed) error {
feed.IgnoreHTTPCache,
feed.AllowSelfSignedCertificates,
feed.FetchViaProxy,
feed.HideGlobally,
).Scan(&feed.ID)
if err != nil {
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,
ignore_http_cache=$21,
allow_self_signed_certificates=$22,
fetch_via_proxy=$23
fetch_via_proxy=$23,
hide_globally=$24
WHERE
id=$24 AND user_id=$25
id=$25 AND user_id=$26
`
_, err = s.db.Exec(query,
feed.FeedURL,
@ -347,6 +350,7 @@ func (s *Storage) UpdateFeed(feed *model.Feed) (err error) {
feed.IgnoreHTTPCache,
feed.AllowSelfSignedCertificates,
feed.FetchViaProxy,
feed.HideGlobally,
feed.ID,
feed.UserID,
)

View File

@ -166,6 +166,7 @@ func (f *FeedQueryBuilder) GetFeeds() (model.Feeds, error) {
f.allow_self_signed_certificates,
f.fetch_via_proxy,
f.disabled,
f.hide_globally,
f.category_id,
c.title as category_title,
fi.icon_id,
@ -226,6 +227,7 @@ func (f *FeedQueryBuilder) GetFeeds() (model.Feeds, error) {
&feed.AllowSelfSignedCertificates,
&feed.FetchViaProxy,
&feed.Disabled,
&feed.HideGlobally,
&feed.Category.ID,
&feed.Category.Title,
&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>
{{ 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="hide_globally" value="1" {{ if .form.HideGlobally }}checked{{ end }}> {{ t "form.feed.label.hide_globally" }}</label>
<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>

View File

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

View File

@ -30,6 +30,7 @@ type FeedForm struct {
AllowSelfSignedCertificates bool
FetchViaProxy bool
Disabled bool
HideGlobally bool
}
// 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.FetchViaProxy = f.FetchViaProxy
feed.Disabled = f.Disabled
feed.HideGlobally = f.HideGlobally
return feed
}
@ -80,5 +82,6 @@ func NewFeedForm(r *http.Request) *FeedForm {
AllowSelfSignedCertificates: r.FormValue("allow_self_signed_certificates") == "1",
FetchViaProxy: r.FormValue("fetch_via_proxy") == "1",
Disabled: r.FormValue("disabled") == "1",
HideGlobally: r.FormValue("hide_globally") == "1",
}
}