From 520a8032347a9edf7300006ecb99eaf54d41491e Mon Sep 17 00:00:00 2001 From: fuchsrot Date: Sat, 26 Aug 2023 09:16:41 +0200 Subject: [PATCH] Apprise Service Urls per feed --- internal/database/migrations.go | 6 ++++++ internal/integration/integration.go | 11 +++++++++-- internal/locale/translations/de_DE.json | 3 ++- internal/locale/translations/el_EL.json | 1 + internal/locale/translations/en_US.json | 1 + internal/locale/translations/es_ES.json | 1 + internal/locale/translations/fi_FI.json | 1 + internal/locale/translations/fr_FR.json | 1 + internal/locale/translations/hi_IN.json | 1 + internal/locale/translations/id_ID.json | 1 + internal/locale/translations/it_IT.json | 1 + internal/locale/translations/ja_JP.json | 1 + internal/locale/translations/nl_NL.json | 1 + internal/locale/translations/pl_PL.json | 1 + internal/locale/translations/pt_BR.json | 1 + internal/locale/translations/ru_RU.json | 1 + internal/locale/translations/tr_TR.json | 1 + internal/locale/translations/uk_UA.json | 1 + internal/locale/translations/zh_CN.json | 1 + internal/locale/translations/zh_TW.json | 1 + internal/model/feed.go | 1 + internal/reader/processor/processor.go | 2 +- internal/storage/feed.go | 10 +++++++--- internal/storage/feed_query_builder.go | 4 +++- internal/template/templates/views/edit_feed.html | 8 ++++++++ internal/ui/feed_edit.go | 1 + internal/ui/form/feed.go | 3 +++ 27 files changed, 58 insertions(+), 8 deletions(-) diff --git a/internal/database/migrations.go b/internal/database/migrations.go index f238993c216..4830acd13fa 100644 --- a/internal/database/migrations.go +++ b/internal/database/migrations.go @@ -752,4 +752,10 @@ var migrations = []func(tx *sql.Tx) error{ _, err = tx.Exec(sql) return err }, + func(tx *sql.Tx) (err error) { + _, err = tx.Exec(` + ALTER TABLE feeds ADD COLUMN apprise_service_urls text default ''; + `) + return err + }, } diff --git a/internal/integration/integration.go b/internal/integration/integration.go index 7385950c63f..65d005d80ea 100644 --- a/internal/integration/integration.go +++ b/internal/integration/integration.go @@ -181,7 +181,7 @@ func PushEntries(entries model.Entries, integration *model.Integration) { } // PushEntry pushes an entry to third-party providers during feed refreshes. -func PushEntry(entry *model.Entry, integration *model.Integration) { +func PushEntry(entry *model.Entry, feed *model.Feed, integration *model.Integration) { if integration.TelegramBotEnabled { logger.Debug("[Integration] Sending Entry %q for User #%d to Telegram", entry.URL, integration.UserID) @@ -193,8 +193,15 @@ func PushEntry(entry *model.Entry, integration *model.Integration) { if integration.AppriseEnabled { logger.Debug("[Integration] Sending Entry %q for User #%d to apprise", entry.URL, integration.UserID) + var appriseServiceURLs string + if len(feed.AppriseServiceURLs) > 0 { + appriseServiceURLs = feed.AppriseServiceURLs + } else { + appriseServiceURLs = integration.AppriseServicesURL + } + client := apprise.NewClient( - integration.AppriseServicesURL, + appriseServiceURLs, integration.AppriseURL, ) diff --git a/internal/locale/translations/de_DE.json b/internal/locale/translations/de_DE.json index bfa263291fe..98774a9b7c4 100644 --- a/internal/locale/translations/de_DE.json +++ b/internal/locale/translations/de_DE.json @@ -282,6 +282,7 @@ "form.feed.label.blocklist_rules": "Blockierregeln", "form.feed.label.keeplist_rules": "Erlaubnisregeln", "form.feed.label.urlrewrite_rules": "Umschreibregeln für URL", + "form.feed.label.apprise_service_urls": "Kommaseparierte Liste der Apprise service URLs", "form.feed.label.ignore_http_cache": "Ignoriere HTTP-cache", "form.feed.label.allow_self_signed_certificates": "Erlaube selbstsignierte oder ungültige Zertifikate", "form.feed.label.fetch_via_proxy": "Über Proxy abrufen", @@ -357,7 +358,7 @@ "form.integration.notion_token": "Notion Secret Token", "form.integration.apprise_activate": "Push entries to Apprise", "form.integration.apprise_url": "Apprise API URL", - "form.integration.apprise_services_url": "Comma separated list of Apprise service URLs", + "form.integration.apprise_services_url": "Kommaseparierte Liste der Apprise service URLs", "form.integration.nunux_keeper_activate": "Artikel in Nunux Keeper speichern", "form.integration.nunux_keeper_endpoint": "Nunux Keeper API-Endpunkt", "form.integration.nunux_keeper_api_key": "Nunux Keeper API-Schlüssel", diff --git a/internal/locale/translations/el_EL.json b/internal/locale/translations/el_EL.json index 83def66d7b5..6dc9cd592a5 100644 --- a/internal/locale/translations/el_EL.json +++ b/internal/locale/translations/el_EL.json @@ -266,6 +266,7 @@ "error.feed_invalid_blocklist_rule": "Ο κανόνας λίστας μπλοκ δεν είναι έγκυρος.", "error.feed_invalid_keeplist_rule": "Ο κανόνας keep list δεν είναι έγκυρος.", "form.feed.label.urlrewrite_rules": "επανεγγραφή κανόνων για τη διεύθυνση URL.", + "form.feed.label.apprise_service_urls": "Comma separated list of Apprise service URLs", "error.user_mandatory_fields": "Το όνομα χρήστη είναι υποχρεωτικό.", "error.api_key_already_exists": "Αυτό το κλειδί API υπάρχει ήδη.", "error.unable_to_create_api_key": "Δεν είναι δυνατή η δημιουργία αυτού του κλειδιού API.", diff --git a/internal/locale/translations/en_US.json b/internal/locale/translations/en_US.json index cef0a26334e..bcec58ca6dd 100644 --- a/internal/locale/translations/en_US.json +++ b/internal/locale/translations/en_US.json @@ -279,6 +279,7 @@ "form.feed.label.cookie": "Set Cookies", "form.feed.label.scraper_rules": "Scraper Rules", "form.feed.label.rewrite_rules": "Rewrite Rules", + "form.feed.label.apprise_service_urls": "Comma separated list of Apprise service URLs", "form.feed.label.blocklist_rules": "Block Rules", "form.feed.label.keeplist_rules": "Keep Rules", "form.feed.label.urlrewrite_rules": "URL Rewrite Rules", diff --git a/internal/locale/translations/es_ES.json b/internal/locale/translations/es_ES.json index f78f0c917fe..5e002ec0057 100644 --- a/internal/locale/translations/es_ES.json +++ b/internal/locale/translations/es_ES.json @@ -279,6 +279,7 @@ "form.feed.label.cookie": "Configurar las cookies", "form.feed.label.scraper_rules": "Reglas de extracción de información", "form.feed.label.rewrite_rules": "Reglas de reescribir", + "form.feed.label.apprise_service_urls": "Comma separated list of Apprise service URLs", "form.feed.label.blocklist_rules": "Reglas de Filtrado (Bloquear)", "form.feed.label.keeplist_rules": "Reglas de Filtrado (Permitir)", "form.feed.label.urlrewrite_rules": "Reglas de Filtrado (Reescritura)", diff --git a/internal/locale/translations/fi_FI.json b/internal/locale/translations/fi_FI.json index 4163dedc03a..41fec82d9e6 100644 --- a/internal/locale/translations/fi_FI.json +++ b/internal/locale/translations/fi_FI.json @@ -266,6 +266,7 @@ "error.feed_invalid_blocklist_rule": "The block list rule is invalid.", "error.feed_invalid_keeplist_rule": "The keep list rule is invalid.", "form.feed.label.urlrewrite_rules": "URL-osoitteen uudelleenkirjoitussäännöt", + "form.feed.label.apprise_service_urls": "Comma separated list of Apprise service URLs", "error.user_mandatory_fields": "Käyttäjätunnus on pakollinen.", "error.api_key_already_exists": "API-avain on jo olemassa.", "error.unable_to_create_api_key": "API-avainta ei voi luoda.", diff --git a/internal/locale/translations/fr_FR.json b/internal/locale/translations/fr_FR.json index fabd3260af2..2069ad3c3af 100644 --- a/internal/locale/translations/fr_FR.json +++ b/internal/locale/translations/fr_FR.json @@ -279,6 +279,7 @@ "form.feed.label.cookie": "Définir les cookies", "form.feed.label.scraper_rules": "Règles pour récupérer le contenu original", "form.feed.label.rewrite_rules": "Règles de réécriture", + "form.feed.label.apprise_service_urls": "Comma separated list of Apprise service URLs", "form.feed.label.blocklist_rules": "Règles de blocage", "form.feed.label.keeplist_rules": "Règles d'autorisation", "form.feed.label.urlrewrite_rules": "Règles de réécriture d'URL", diff --git a/internal/locale/translations/hi_IN.json b/internal/locale/translations/hi_IN.json index cdd3e5f9041..89ce57a9a5a 100644 --- a/internal/locale/translations/hi_IN.json +++ b/internal/locale/translations/hi_IN.json @@ -279,6 +279,7 @@ "form.feed.label.cookie": "कुकीज़ सेट करें", "form.feed.label.scraper_rules": "खुरचनी नियम", "form.feed.label.rewrite_rules": "नियम फिर से लिखें", + "form.feed.label.apprise_service_urls": "Comma separated list of Apprise service URLs", "form.feed.label.blocklist_rules": "ब्लॉक नियम", "form.feed.label.keeplist_rules": "नियम बनाए रखें", "form.feed.label.urlrewrite_rules": " यूआरएल पुनर्लेखन नियम", diff --git a/internal/locale/translations/id_ID.json b/internal/locale/translations/id_ID.json index d6688e0c8b3..efc07073826 100644 --- a/internal/locale/translations/id_ID.json +++ b/internal/locale/translations/id_ID.json @@ -276,6 +276,7 @@ "form.feed.label.cookie": "Atur Kuki", "form.feed.label.scraper_rules": "Aturan Pengambil Data", "form.feed.label.rewrite_rules": "Aturan Tulis Ulang", + "form.feed.label.apprise_service_urls": "Comma separated list of Apprise service URLs", "form.feed.label.blocklist_rules": "Aturan Blokir", "form.feed.label.keeplist_rules": "Aturan Simpan", "form.feed.label.urlrewrite_rules": "Aturan Tulis Ulang URL", diff --git a/internal/locale/translations/it_IT.json b/internal/locale/translations/it_IT.json index 8bffcd14c68..78363f1b563 100644 --- a/internal/locale/translations/it_IT.json +++ b/internal/locale/translations/it_IT.json @@ -279,6 +279,7 @@ "form.feed.label.cookie": "Installare i cookies", "form.feed.label.scraper_rules": "Regole di estrazione del contenuto", "form.feed.label.rewrite_rules": "Regole di impaginazione del contenuto", + "form.feed.label.apprise_service_urls": "Comma separated list of Apprise service URLs", "form.feed.label.blocklist_rules": "Regole di blocco", "form.feed.label.keeplist_rules": "Regole di autorizzazione", "form.feed.label.urlrewrite_rules": "Regole di riscrittura URL", diff --git a/internal/locale/translations/ja_JP.json b/internal/locale/translations/ja_JP.json index e88f26c80e2..71e9abe5178 100644 --- a/internal/locale/translations/ja_JP.json +++ b/internal/locale/translations/ja_JP.json @@ -282,6 +282,7 @@ "form.feed.label.blocklist_rules": "Block ルール", "form.feed.label.keeplist_rules": "Keep ルール", "form.feed.label.urlrewrite_rules": "Rewrite URL ルール", + "form.feed.label.apprise_service_urls": "Comma separated list of Apprise service URLs", "form.feed.label.ignore_http_cache": "HTTPキャッシュを無視", "form.feed.label.allow_self_signed_certificates": "自己署名証明書または無効な証明書を許可する", "form.feed.label.fetch_via_proxy": "プロキシ経由で取得", diff --git a/internal/locale/translations/nl_NL.json b/internal/locale/translations/nl_NL.json index 1403208b77f..8013bba8da6 100644 --- a/internal/locale/translations/nl_NL.json +++ b/internal/locale/translations/nl_NL.json @@ -282,6 +282,7 @@ "form.feed.label.blocklist_rules": "Blokkeer regels", "form.feed.label.keeplist_rules": "toestemmingsregels", "form.feed.label.urlrewrite_rules": "Regels voor het herschrijven van URL's", + "form.feed.label.apprise_service_urls": "Comma separated list of Apprise service URLs", "form.feed.label.ignore_http_cache": "Negeer HTTP-cache", "form.feed.label.allow_self_signed_certificates": "Sta zelfondertekende of ongeldige certificaten toe", "form.feed.label.fetch_via_proxy": "Ophalen via proxy", diff --git a/internal/locale/translations/pl_PL.json b/internal/locale/translations/pl_PL.json index cea71451b02..41b80ad44e3 100644 --- a/internal/locale/translations/pl_PL.json +++ b/internal/locale/translations/pl_PL.json @@ -284,6 +284,7 @@ "form.feed.label.blocklist_rules": "Zasady blokowania", "form.feed.label.keeplist_rules": "Zasady zezwoleń", "form.feed.label.urlrewrite_rules": "Zasady przepisywania adresów URL", + "form.feed.label.apprise_service_urls": "Comma separated list of Apprise service URLs", "form.feed.label.ignore_http_cache": "Zignoruj ​​pamięć podręczną HTTP", "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", diff --git a/internal/locale/translations/pt_BR.json b/internal/locale/translations/pt_BR.json index d1dcce60cb2..c85b0d32596 100644 --- a/internal/locale/translations/pt_BR.json +++ b/internal/locale/translations/pt_BR.json @@ -282,6 +282,7 @@ "form.feed.label.blocklist_rules": "Regras de bloqueio", "form.feed.label.keeplist_rules": "Regras de permissão", "form.feed.label.urlrewrite_rules": "Regras de reescrita de URL", + "form.feed.label.apprise_service_urls": "Comma separated list of Apprise service URLs", "form.feed.label.ignore_http_cache": "Ignorar cache HTTP", "form.feed.label.allow_self_signed_certificates": "Permitir certificados autoassinados ou inválidos", "form.feed.label.disabled": "Não atualizar esta fonte", diff --git a/internal/locale/translations/ru_RU.json b/internal/locale/translations/ru_RU.json index d7b473d1ad7..7eb0a2e9902 100644 --- a/internal/locale/translations/ru_RU.json +++ b/internal/locale/translations/ru_RU.json @@ -284,6 +284,7 @@ "form.feed.label.blocklist_rules": "Правила черного списка", "form.feed.label.keeplist_rules": "Правила белого списка", "form.feed.label.urlrewrite_rules": "Правила перезаписи URL", + "form.feed.label.apprise_service_urls": "Comma separated list of Apprise service URLs", "form.feed.label.ignore_http_cache": "Игнорировать HTTP кеш", "form.feed.label.allow_self_signed_certificates": "Разрешить самоподписанные или недействительные сертификаты", "form.feed.label.fetch_via_proxy": "Использовать прокси", diff --git a/internal/locale/translations/tr_TR.json b/internal/locale/translations/tr_TR.json index 572aad1b7b9..fb74da258e0 100644 --- a/internal/locale/translations/tr_TR.json +++ b/internal/locale/translations/tr_TR.json @@ -282,6 +282,7 @@ "form.feed.label.blocklist_rules": "Engelleme Kuralları", "form.feed.label.keeplist_rules": "Saklama Kuralları", "form.feed.label.urlrewrite_rules": "URL Yeniden Yazma Kuralları", + "form.feed.label.apprise_service_urls": "Comma separated list of Apprise service URLs", "form.feed.label.ignore_http_cache": "HTTP önbelleğini yoksay", "form.feed.label.allow_self_signed_certificates": "Kendinden imzalı veya geçersiz sertifikalara izin ver", "form.feed.label.fetch_via_proxy": "Proxy ile çek", diff --git a/internal/locale/translations/uk_UA.json b/internal/locale/translations/uk_UA.json index a92e285af91..2896d6920d7 100644 --- a/internal/locale/translations/uk_UA.json +++ b/internal/locale/translations/uk_UA.json @@ -285,6 +285,7 @@ "form.feed.label.blocklist_rules": "Правила блокування", "form.feed.label.keeplist_rules": "Правила дозволення", "form.feed.label.urlrewrite_rules": "Правила перезапису URL-адрес", + "form.feed.label.apprise_service_urls": "Comma separated list of Apprise service URLs", "form.feed.label.ignore_http_cache": "Ігнорувати кеш HTTP", "form.feed.label.allow_self_signed_certificates": "Дозволити сертифікати з власним підписом або недійсні", "form.feed.label.fetch_via_proxy": "Використати проксі-сервер", diff --git a/internal/locale/translations/zh_CN.json b/internal/locale/translations/zh_CN.json index 0acf016adeb..a3b430a3745 100644 --- a/internal/locale/translations/zh_CN.json +++ b/internal/locale/translations/zh_CN.json @@ -280,6 +280,7 @@ "form.feed.label.blocklist_rules": "阻止规则", "form.feed.label.keeplist_rules": "保留规则", "form.feed.label.urlrewrite_rules": "URL 重写规则", + "form.feed.label.apprise_service_urls": "Comma separated list of Apprise service URLs", "form.feed.label.ignore_http_cache": "忽略 HTTP 缓存", "form.feed.label.allow_self_signed_certificates": "允许自签名证书或无效证书", "form.feed.label.fetch_via_proxy": "通过代理获取", diff --git a/internal/locale/translations/zh_TW.json b/internal/locale/translations/zh_TW.json index 817884e2ebf..45c441652b2 100644 --- a/internal/locale/translations/zh_TW.json +++ b/internal/locale/translations/zh_TW.json @@ -282,6 +282,7 @@ "form.feed.label.blocklist_rules": "過濾規則", "form.feed.label.keeplist_rules": "保留規則", "form.feed.label.urlrewrite_rules": "URL 重写规则", + "form.feed.label.apprise_service_urls": "Comma separated list of Apprise service URLs", "form.feed.label.ignore_http_cache": "忽略 HTTP 快取", "form.feed.label.allow_self_signed_certificates": "允許自簽章憑證或無效憑證", "form.feed.label.fetch_via_proxy": "透過代理獲取", diff --git a/internal/model/feed.go b/internal/model/feed.go index 4add53b676f..a00a9d314bb 100644 --- a/internal/model/feed.go +++ b/internal/model/feed.go @@ -56,6 +56,7 @@ type Feed struct { HideGlobally bool `json:"hide_globally"` UnreadCount int `json:"-"` ReadCount int `json:"-"` + AppriseServiceURLs string `json:"apprise_service_urls"` } type FeedCounters struct { diff --git a/internal/reader/processor/processor.go b/internal/reader/processor/processor.go index 2deac4cf674..4dec59f0d0a 100644 --- a/internal/reader/processor/processor.go +++ b/internal/reader/processor/processor.go @@ -97,7 +97,7 @@ func ProcessFeedEntries(store *storage.Storage, feed *model.Feed, user *model.Us } else if intg != nil { localEntry := entry go func() { - integration.PushEntry(localEntry, intg) + integration.PushEntry(localEntry, feed, intg) }() entriesToPush = append(entriesToPush, localEntry) } diff --git a/internal/storage/feed.go b/internal/storage/feed.go index e049c31e679..01fba798755 100644 --- a/internal/storage/feed.go +++ b/internal/storage/feed.go @@ -240,10 +240,11 @@ func (s *Storage) CreateFeed(feed *model.Feed) error { fetch_via_proxy, hide_globally, url_rewrite_rules, - no_media_player + no_media_player, + apprise_service_urls ) VALUES - ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23) + ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24) RETURNING id ` @@ -272,6 +273,7 @@ func (s *Storage) CreateFeed(feed *model.Feed) error { feed.HideGlobally, feed.UrlRewriteRules, feed.NoMediaPlayer, + feed.AppriseServiceURLs, ).Scan(&feed.ID) if err != nil { return fmt.Errorf(`store: unable to create feed %q: %v`, feed.FeedURL, err) @@ -342,7 +344,8 @@ func (s *Storage) UpdateFeed(feed *model.Feed) (err error) { fetch_via_proxy=$23, hide_globally=$24, url_rewrite_rules=$25, - no_media_player=$26 + no_media_player=$26, + apprise_service_urls=$29 WHERE id=$27 AND user_id=$28 ` @@ -375,6 +378,7 @@ func (s *Storage) UpdateFeed(feed *model.Feed) (err error) { feed.NoMediaPlayer, feed.ID, feed.UserID, + feed.AppriseServiceURLs, ) if err != nil { diff --git a/internal/storage/feed_query_builder.go b/internal/storage/feed_query_builder.go index b9360d72538..105d72cc8ec 100644 --- a/internal/storage/feed_query_builder.go +++ b/internal/storage/feed_query_builder.go @@ -161,7 +161,8 @@ func (f *FeedQueryBuilder) GetFeeds() (model.Feeds, error) { c.title as category_title, c.hide_globally as category_hidden, fi.icon_id, - u.timezone + u.timezone, + f.apprise_service_urls FROM feeds f LEFT JOIN @@ -226,6 +227,7 @@ func (f *FeedQueryBuilder) GetFeeds() (model.Feeds, error) { &feed.Category.HideGlobally, &iconID, &tz, + &feed.AppriseServiceURLs, ) if err != nil { diff --git a/internal/template/templates/views/edit_feed.html b/internal/template/templates/views/edit_feed.html index 12338ce35ed..170f1901315 100644 --- a/internal/template/templates/views/edit_feed.html +++ b/internal/template/templates/views/edit_feed.html @@ -129,6 +129,14 @@

{{ t "page.edit_feed.last_parsing_error" }}

+
+ +   +
+ + diff --git a/internal/ui/feed_edit.go b/internal/ui/feed_edit.go index a9bb4fe7821..e758faa5959 100644 --- a/internal/ui/feed_edit.go +++ b/internal/ui/feed_edit.go @@ -61,6 +61,7 @@ func (h *handler) showEditFeedPage(w http.ResponseWriter, r *http.Request) { NoMediaPlayer: feed.NoMediaPlayer, HideGlobally: feed.HideGlobally, CategoryHidden: feed.Category.HideGlobally, + AppriseServiceURLs: feed.AppriseServiceURLs, } sess := session.New(h.store, request.SessionID(r)) diff --git a/internal/ui/form/feed.go b/internal/ui/form/feed.go index 2e8bbd86c67..e0ed319e283 100644 --- a/internal/ui/form/feed.go +++ b/internal/ui/form/feed.go @@ -33,6 +33,7 @@ type FeedForm struct { NoMediaPlayer bool HideGlobally bool CategoryHidden bool // Category has "hide_globally" + AppriseServiceURLs string } // Merge updates the fields of the given feed. @@ -59,6 +60,7 @@ func (f FeedForm) Merge(feed *model.Feed) *model.Feed { feed.Disabled = f.Disabled feed.NoMediaPlayer = f.NoMediaPlayer feed.HideGlobally = f.HideGlobally + feed.AppriseServiceURLs = f.AppriseServiceURLs return feed } @@ -89,5 +91,6 @@ func NewFeedForm(r *http.Request) *FeedForm { Disabled: r.FormValue("disabled") == "1", NoMediaPlayer: r.FormValue("no_media_player") == "1", HideGlobally: r.FormValue("hide_globally") == "1", + AppriseServiceURLs: r.FormValue("apprise_service_urls"), } }