integration.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. package integration // import "miniflux.app/v2/internal/integration"
  4. import (
  5. "log/slog"
  6. "miniflux.app/v2/internal/config"
  7. "miniflux.app/v2/internal/integration/apprise"
  8. "miniflux.app/v2/internal/integration/betula"
  9. "miniflux.app/v2/internal/integration/cubox"
  10. "miniflux.app/v2/internal/integration/discord"
  11. "miniflux.app/v2/internal/integration/espial"
  12. "miniflux.app/v2/internal/integration/instapaper"
  13. "miniflux.app/v2/internal/integration/linkace"
  14. "miniflux.app/v2/internal/integration/linkding"
  15. "miniflux.app/v2/internal/integration/linkwarden"
  16. "miniflux.app/v2/internal/integration/matrixbot"
  17. "miniflux.app/v2/internal/integration/notion"
  18. "miniflux.app/v2/internal/integration/ntfy"
  19. "miniflux.app/v2/internal/integration/nunuxkeeper"
  20. "miniflux.app/v2/internal/integration/omnivore"
  21. "miniflux.app/v2/internal/integration/pinboard"
  22. "miniflux.app/v2/internal/integration/pocket"
  23. "miniflux.app/v2/internal/integration/pushover"
  24. "miniflux.app/v2/internal/integration/raindrop"
  25. "miniflux.app/v2/internal/integration/readeck"
  26. "miniflux.app/v2/internal/integration/readwise"
  27. "miniflux.app/v2/internal/integration/shaarli"
  28. "miniflux.app/v2/internal/integration/shiori"
  29. "miniflux.app/v2/internal/integration/slack"
  30. "miniflux.app/v2/internal/integration/telegrambot"
  31. "miniflux.app/v2/internal/integration/wallabag"
  32. "miniflux.app/v2/internal/integration/webhook"
  33. "miniflux.app/v2/internal/model"
  34. )
  35. // SendEntry sends the entry to third-party providers when the user click on "Save".
  36. func SendEntry(entry *model.Entry, userIntegrations *model.Integration) {
  37. if userIntegrations.BetulaEnabled {
  38. slog.Debug("Sending entry to Betula",
  39. slog.Int64("user_id", userIntegrations.UserID),
  40. slog.Int64("entry_id", entry.ID),
  41. slog.String("entry_url", entry.URL),
  42. )
  43. client := betula.NewClient(userIntegrations.BetulaURL, userIntegrations.BetulaToken)
  44. err := client.CreateBookmark(
  45. entry.URL,
  46. entry.Title,
  47. entry.Tags,
  48. )
  49. if err != nil {
  50. slog.Error("Unable to send entry to Betula",
  51. slog.Int64("user_id", userIntegrations.UserID),
  52. slog.Int64("entry_id", entry.ID),
  53. slog.String("entry_url", entry.URL),
  54. slog.Any("error", err),
  55. )
  56. }
  57. }
  58. if userIntegrations.PinboardEnabled {
  59. slog.Debug("Sending entry to Pinboard",
  60. slog.Int64("user_id", userIntegrations.UserID),
  61. slog.Int64("entry_id", entry.ID),
  62. slog.String("entry_url", entry.URL),
  63. )
  64. client := pinboard.NewClient(userIntegrations.PinboardToken)
  65. err := client.CreateBookmark(
  66. entry.URL,
  67. entry.Title,
  68. userIntegrations.PinboardTags,
  69. userIntegrations.PinboardMarkAsUnread,
  70. )
  71. if err != nil {
  72. slog.Error("Unable to send entry to Pinboard",
  73. slog.Int64("user_id", userIntegrations.UserID),
  74. slog.Int64("entry_id", entry.ID),
  75. slog.String("entry_url", entry.URL),
  76. slog.Any("error", err),
  77. )
  78. }
  79. }
  80. if userIntegrations.InstapaperEnabled {
  81. slog.Debug("Sending entry to Instapaper",
  82. slog.Int64("user_id", userIntegrations.UserID),
  83. slog.Int64("entry_id", entry.ID),
  84. slog.String("entry_url", entry.URL),
  85. )
  86. client := instapaper.NewClient(userIntegrations.InstapaperUsername, userIntegrations.InstapaperPassword)
  87. if err := client.AddURL(entry.URL, entry.Title); err != nil {
  88. slog.Error("Unable to send entry to Instapaper",
  89. slog.Int64("user_id", userIntegrations.UserID),
  90. slog.Int64("entry_id", entry.ID),
  91. slog.String("entry_url", entry.URL),
  92. slog.Any("error", err),
  93. )
  94. }
  95. }
  96. if userIntegrations.WallabagEnabled {
  97. slog.Debug("Sending entry to Wallabag",
  98. slog.Int64("user_id", userIntegrations.UserID),
  99. slog.Int64("entry_id", entry.ID),
  100. slog.String("entry_url", entry.URL),
  101. )
  102. client := wallabag.NewClient(
  103. userIntegrations.WallabagURL,
  104. userIntegrations.WallabagClientID,
  105. userIntegrations.WallabagClientSecret,
  106. userIntegrations.WallabagUsername,
  107. userIntegrations.WallabagPassword,
  108. userIntegrations.WallabagOnlyURL,
  109. )
  110. if err := client.CreateEntry(entry.URL, entry.Title, entry.Content); err != nil {
  111. slog.Error("Unable to send entry to Wallabag",
  112. slog.Int64("user_id", userIntegrations.UserID),
  113. slog.Int64("entry_id", entry.ID),
  114. slog.String("entry_url", entry.URL),
  115. slog.Any("error", err),
  116. )
  117. }
  118. }
  119. if userIntegrations.NotionEnabled {
  120. slog.Debug("Sending entry to Notion",
  121. slog.Int64("user_id", userIntegrations.UserID),
  122. slog.Int64("entry_id", entry.ID),
  123. slog.String("entry_url", entry.URL),
  124. )
  125. client := notion.NewClient(
  126. userIntegrations.NotionToken,
  127. userIntegrations.NotionPageID,
  128. )
  129. if err := client.UpdateDocument(entry.URL, entry.Title); err != nil {
  130. slog.Error("Unable to send entry to Notion",
  131. slog.Int64("user_id", userIntegrations.UserID),
  132. slog.Int64("entry_id", entry.ID),
  133. slog.String("entry_url", entry.URL),
  134. slog.Any("error", err),
  135. )
  136. }
  137. }
  138. if userIntegrations.NunuxKeeperEnabled {
  139. slog.Debug("Sending entry to NunuxKeeper",
  140. slog.Int64("user_id", userIntegrations.UserID),
  141. slog.Int64("entry_id", entry.ID),
  142. slog.String("entry_url", entry.URL),
  143. )
  144. client := nunuxkeeper.NewClient(
  145. userIntegrations.NunuxKeeperURL,
  146. userIntegrations.NunuxKeeperAPIKey,
  147. )
  148. if err := client.AddEntry(entry.URL, entry.Title, entry.Content); err != nil {
  149. slog.Error("Unable to send entry to NunuxKeeper",
  150. slog.Int64("user_id", userIntegrations.UserID),
  151. slog.Int64("entry_id", entry.ID),
  152. slog.String("entry_url", entry.URL),
  153. slog.Any("error", err),
  154. )
  155. }
  156. }
  157. if userIntegrations.EspialEnabled {
  158. slog.Debug("Sending entry to Espial",
  159. slog.Int64("user_id", userIntegrations.UserID),
  160. slog.Int64("entry_id", entry.ID),
  161. slog.String("entry_url", entry.URL),
  162. )
  163. client := espial.NewClient(
  164. userIntegrations.EspialURL,
  165. userIntegrations.EspialAPIKey,
  166. )
  167. if err := client.CreateLink(entry.URL, entry.Title, userIntegrations.EspialTags); err != nil {
  168. slog.Error("Unable to send entry to Espial",
  169. slog.Int64("user_id", userIntegrations.UserID),
  170. slog.Int64("entry_id", entry.ID),
  171. slog.String("entry_url", entry.URL),
  172. slog.Any("error", err),
  173. )
  174. }
  175. }
  176. if userIntegrations.PocketEnabled {
  177. slog.Debug("Sending entry to Pocket",
  178. slog.Int64("user_id", userIntegrations.UserID),
  179. slog.Int64("entry_id", entry.ID),
  180. slog.String("entry_url", entry.URL),
  181. )
  182. client := pocket.NewClient(config.Opts.PocketConsumerKey(userIntegrations.PocketConsumerKey), userIntegrations.PocketAccessToken)
  183. if err := client.AddURL(entry.URL, entry.Title); err != nil {
  184. slog.Error("Unable to send entry to Pocket",
  185. slog.Int64("user_id", userIntegrations.UserID),
  186. slog.Int64("entry_id", entry.ID),
  187. slog.String("entry_url", entry.URL),
  188. slog.Any("error", err),
  189. )
  190. }
  191. }
  192. if userIntegrations.LinkAceEnabled {
  193. slog.Debug("Sending entry to LinkAce",
  194. slog.Int64("user_id", userIntegrations.UserID),
  195. slog.Int64("entry_id", entry.ID),
  196. slog.String("entry_url", entry.URL),
  197. )
  198. client := linkace.NewClient(
  199. userIntegrations.LinkAceURL,
  200. userIntegrations.LinkAceAPIKey,
  201. userIntegrations.LinkAceTags,
  202. userIntegrations.LinkAcePrivate,
  203. userIntegrations.LinkAceCheckDisabled,
  204. )
  205. if err := client.AddURL(entry.URL, entry.Title); err != nil {
  206. slog.Error("Unable to send entry to LinkAce",
  207. slog.Int64("user_id", userIntegrations.UserID),
  208. slog.Int64("entry_id", entry.ID),
  209. slog.String("entry_url", entry.URL),
  210. slog.Any("error", err),
  211. )
  212. }
  213. }
  214. if userIntegrations.LinkdingEnabled {
  215. slog.Debug("Sending entry to Linkding",
  216. slog.Int64("user_id", userIntegrations.UserID),
  217. slog.Int64("entry_id", entry.ID),
  218. slog.String("entry_url", entry.URL),
  219. )
  220. client := linkding.NewClient(
  221. userIntegrations.LinkdingURL,
  222. userIntegrations.LinkdingAPIKey,
  223. userIntegrations.LinkdingTags,
  224. userIntegrations.LinkdingMarkAsUnread,
  225. )
  226. if err := client.CreateBookmark(entry.URL, entry.Title); err != nil {
  227. slog.Error("Unable to send entry to Linkding",
  228. slog.Int64("user_id", userIntegrations.UserID),
  229. slog.Int64("entry_id", entry.ID),
  230. slog.String("entry_url", entry.URL),
  231. slog.Any("error", err),
  232. )
  233. }
  234. }
  235. if userIntegrations.LinkwardenEnabled {
  236. slog.Debug("Sending entry to linkwarden",
  237. slog.Int64("user_id", userIntegrations.UserID),
  238. slog.Int64("entry_id", entry.ID),
  239. slog.String("entry_url", entry.URL),
  240. )
  241. client := linkwarden.NewClient(
  242. userIntegrations.LinkwardenURL,
  243. userIntegrations.LinkwardenAPIKey,
  244. )
  245. if err := client.CreateBookmark(entry.URL, entry.Title); err != nil {
  246. slog.Error("Unable to send entry to Linkwarden",
  247. slog.Int64("user_id", userIntegrations.UserID),
  248. slog.Int64("entry_id", entry.ID),
  249. slog.String("entry_url", entry.URL),
  250. slog.Any("error", err),
  251. )
  252. }
  253. }
  254. if userIntegrations.ReadeckEnabled {
  255. slog.Debug("Sending entry to Readeck",
  256. slog.Int64("user_id", userIntegrations.UserID),
  257. slog.Int64("entry_id", entry.ID),
  258. slog.String("entry_url", entry.URL),
  259. )
  260. client := readeck.NewClient(
  261. userIntegrations.ReadeckURL,
  262. userIntegrations.ReadeckAPIKey,
  263. userIntegrations.ReadeckLabels,
  264. userIntegrations.ReadeckOnlyURL,
  265. )
  266. if err := client.CreateBookmark(entry.URL, entry.Title, entry.Content); err != nil {
  267. slog.Error("Unable to send entry to Readeck",
  268. slog.Int64("user_id", userIntegrations.UserID),
  269. slog.Int64("entry_id", entry.ID),
  270. slog.String("entry_url", entry.URL),
  271. slog.Any("error", err),
  272. )
  273. }
  274. }
  275. if userIntegrations.ReadwiseEnabled {
  276. slog.Debug("Sending entry to Readwise",
  277. slog.Int64("user_id", userIntegrations.UserID),
  278. slog.Int64("entry_id", entry.ID),
  279. slog.String("entry_url", entry.URL),
  280. )
  281. client := readwise.NewClient(
  282. userIntegrations.ReadwiseAPIKey,
  283. )
  284. if err := client.CreateDocument(entry.URL); err != nil {
  285. slog.Error("Unable to send entry to Readwise",
  286. slog.Int64("user_id", userIntegrations.UserID),
  287. slog.Int64("entry_id", entry.ID),
  288. slog.String("entry_url", entry.URL),
  289. slog.Any("error", err),
  290. )
  291. }
  292. }
  293. if userIntegrations.CuboxEnabled {
  294. slog.Debug("Sending entry to Cubox",
  295. slog.Int64("user_id", userIntegrations.UserID),
  296. slog.Int64("entry_id", entry.ID),
  297. slog.String("entry_url", entry.URL),
  298. )
  299. client := cubox.NewClient(userIntegrations.CuboxAPILink)
  300. if err := client.SaveLink(entry.URL); err != nil {
  301. slog.Error("Unable to send entry to Cubox",
  302. slog.Int64("user_id", userIntegrations.UserID),
  303. slog.Int64("entry_id", entry.ID),
  304. slog.String("entry_url", entry.URL),
  305. slog.Any("error", err),
  306. )
  307. }
  308. }
  309. if userIntegrations.ShioriEnabled {
  310. slog.Debug("Sending entry to Shiori",
  311. slog.Int64("user_id", userIntegrations.UserID),
  312. slog.Int64("entry_id", entry.ID),
  313. slog.String("entry_url", entry.URL),
  314. )
  315. client := shiori.NewClient(
  316. userIntegrations.ShioriURL,
  317. userIntegrations.ShioriUsername,
  318. userIntegrations.ShioriPassword,
  319. )
  320. if err := client.CreateBookmark(entry.URL, entry.Title); err != nil {
  321. slog.Error("Unable to send entry to Shiori",
  322. slog.Int64("user_id", userIntegrations.UserID),
  323. slog.Int64("entry_id", entry.ID),
  324. slog.String("entry_url", entry.URL),
  325. slog.Any("error", err),
  326. )
  327. }
  328. }
  329. if userIntegrations.ShaarliEnabled {
  330. slog.Debug("Sending entry to Shaarli",
  331. slog.Int64("user_id", userIntegrations.UserID),
  332. slog.Int64("entry_id", entry.ID),
  333. slog.String("entry_url", entry.URL),
  334. )
  335. client := shaarli.NewClient(
  336. userIntegrations.ShaarliURL,
  337. userIntegrations.ShaarliAPISecret,
  338. )
  339. if err := client.CreateLink(entry.URL, entry.Title); err != nil {
  340. slog.Error("Unable to send entry to Shaarli",
  341. slog.Int64("user_id", userIntegrations.UserID),
  342. slog.Int64("entry_id", entry.ID),
  343. slog.String("entry_url", entry.URL),
  344. slog.Any("error", err),
  345. )
  346. }
  347. }
  348. if userIntegrations.WebhookEnabled {
  349. slog.Debug("Sending entry to Webhook",
  350. slog.Int64("user_id", userIntegrations.UserID),
  351. slog.Int64("entry_id", entry.ID),
  352. slog.String("entry_url", entry.URL),
  353. slog.String("webhook_url", userIntegrations.WebhookURL),
  354. )
  355. webhookClient := webhook.NewClient(userIntegrations.WebhookURL, userIntegrations.WebhookSecret)
  356. if err := webhookClient.SendSaveEntryWebhookEvent(entry); err != nil {
  357. slog.Error("Unable to send entry to Webhook",
  358. slog.Int64("user_id", userIntegrations.UserID),
  359. slog.Int64("entry_id", entry.ID),
  360. slog.String("entry_url", entry.URL),
  361. slog.String("webhook_url", userIntegrations.WebhookURL),
  362. slog.Any("error", err),
  363. )
  364. }
  365. }
  366. if userIntegrations.OmnivoreEnabled {
  367. slog.Debug("Sending entry to Omnivore",
  368. slog.Int64("user_id", userIntegrations.UserID),
  369. slog.Int64("entry_id", entry.ID),
  370. slog.String("entry_url", entry.URL),
  371. )
  372. client := omnivore.NewClient(userIntegrations.OmnivoreAPIKey, userIntegrations.OmnivoreURL)
  373. if err := client.SaveUrl(entry.URL); err != nil {
  374. slog.Error("Unable to send entry to Omnivore",
  375. slog.Int64("user_id", userIntegrations.UserID),
  376. slog.Int64("entry_id", entry.ID),
  377. slog.String("entry_url", entry.URL),
  378. slog.Any("error", err),
  379. )
  380. }
  381. }
  382. if userIntegrations.RaindropEnabled {
  383. slog.Debug("Sending entry to Raindrop",
  384. slog.Int64("user_id", userIntegrations.UserID),
  385. slog.Int64("entry_id", entry.ID),
  386. slog.String("entry_url", entry.URL),
  387. )
  388. client := raindrop.NewClient(userIntegrations.RaindropToken, userIntegrations.RaindropCollectionID, userIntegrations.RaindropTags)
  389. if err := client.CreateRaindrop(entry.URL, entry.Title); err != nil {
  390. slog.Error("Unable to send entry to Raindrop",
  391. slog.Int64("user_id", userIntegrations.UserID),
  392. slog.Int64("entry_id", entry.ID),
  393. slog.String("entry_url", entry.URL),
  394. slog.Any("error", err),
  395. )
  396. }
  397. }
  398. }
  399. // PushEntries pushes a list of entries to activated third-party providers during feed refreshes.
  400. func PushEntries(feed *model.Feed, entries model.Entries, userIntegrations *model.Integration) {
  401. if userIntegrations.MatrixBotEnabled {
  402. slog.Debug("Sending new entries to Matrix",
  403. slog.Int64("user_id", userIntegrations.UserID),
  404. slog.Int("nb_entries", len(entries)),
  405. slog.Int64("feed_id", feed.ID),
  406. )
  407. err := matrixbot.PushEntries(
  408. feed,
  409. entries,
  410. userIntegrations.MatrixBotURL,
  411. userIntegrations.MatrixBotUser,
  412. userIntegrations.MatrixBotPassword,
  413. userIntegrations.MatrixBotChatID,
  414. )
  415. if err != nil {
  416. slog.Error("Unable to send new entries to Matrix",
  417. slog.Int64("user_id", userIntegrations.UserID),
  418. slog.Int("nb_entries", len(entries)),
  419. slog.Int64("feed_id", feed.ID),
  420. slog.Any("error", err),
  421. )
  422. }
  423. }
  424. if userIntegrations.WebhookEnabled {
  425. var webhookURL string
  426. if feed.WebhookURL != "" {
  427. webhookURL = feed.WebhookURL
  428. } else {
  429. webhookURL = userIntegrations.WebhookURL
  430. }
  431. slog.Debug("Sending new entries to Webhook",
  432. slog.Int64("user_id", userIntegrations.UserID),
  433. slog.Int("nb_entries", len(entries)),
  434. slog.Int64("feed_id", feed.ID),
  435. slog.String("webhook_url", webhookURL),
  436. )
  437. webhookClient := webhook.NewClient(webhookURL, userIntegrations.WebhookSecret)
  438. if err := webhookClient.SendNewEntriesWebhookEvent(feed, entries); err != nil {
  439. slog.Debug("Unable to send new entries to Webhook",
  440. slog.Int64("user_id", userIntegrations.UserID),
  441. slog.Int("nb_entries", len(entries)),
  442. slog.Int64("feed_id", feed.ID),
  443. slog.String("webhook_url", webhookURL),
  444. slog.Any("error", err),
  445. )
  446. }
  447. }
  448. if userIntegrations.NtfyEnabled && feed.NtfyEnabled {
  449. ntfyTopic := feed.NtfyTopic
  450. if ntfyTopic == "" {
  451. ntfyTopic = userIntegrations.NtfyTopic
  452. }
  453. slog.Debug("Sending new entries to Ntfy",
  454. slog.Int64("user_id", userIntegrations.UserID),
  455. slog.Int("nb_entries", len(entries)),
  456. slog.Int64("feed_id", feed.ID),
  457. slog.String("topic", ntfyTopic),
  458. )
  459. client := ntfy.NewClient(
  460. userIntegrations.NtfyURL,
  461. ntfyTopic,
  462. userIntegrations.NtfyAPIToken,
  463. userIntegrations.NtfyUsername,
  464. userIntegrations.NtfyPassword,
  465. userIntegrations.NtfyIconURL,
  466. userIntegrations.NtfyInternalLinks,
  467. feed.NtfyPriority,
  468. )
  469. if err := client.SendMessages(feed, entries); err != nil {
  470. slog.Warn("Unable to send new entries to Ntfy", slog.Any("error", err))
  471. }
  472. }
  473. if userIntegrations.AppriseEnabled {
  474. slog.Debug("Sending new entries to Apprise",
  475. slog.Int64("user_id", userIntegrations.UserID),
  476. slog.Int("nb_entries", len(entries)),
  477. slog.Int64("feed_id", feed.ID),
  478. )
  479. appriseServiceURLs := userIntegrations.AppriseServicesURL
  480. if feed.AppriseServiceURLs != "" {
  481. appriseServiceURLs = feed.AppriseServiceURLs
  482. }
  483. client := apprise.NewClient(
  484. appriseServiceURLs,
  485. userIntegrations.AppriseURL,
  486. )
  487. if err := client.SendNotification(feed, entries); err != nil {
  488. slog.Warn("Unable to send new entries to Apprise", slog.Any("error", err))
  489. }
  490. }
  491. if userIntegrations.DiscordEnabled {
  492. slog.Debug("Sending new entries to Discord",
  493. slog.Int64("user_id", userIntegrations.UserID),
  494. slog.Int("nb_entries", len(entries)),
  495. slog.Int64("feed_id", feed.ID),
  496. )
  497. client := discord.NewClient(
  498. userIntegrations.DiscordWebhookLink,
  499. )
  500. if err := client.SendDiscordMsg(feed, entries); err != nil {
  501. slog.Warn("Unable to send new entries to Discord", slog.Any("error", err))
  502. }
  503. }
  504. if userIntegrations.SlackEnabled {
  505. slog.Debug("Sending new entries to Slack",
  506. slog.Int64("user_id", userIntegrations.UserID),
  507. slog.Int("nb_entries", len(entries)),
  508. slog.Int64("feed_id", feed.ID),
  509. )
  510. client := slack.NewClient(
  511. userIntegrations.SlackWebhookLink,
  512. )
  513. if err := client.SendSlackMsg(feed, entries); err != nil {
  514. slog.Warn("Unable to send new entries to Slack", slog.Any("error", err))
  515. }
  516. }
  517. if userIntegrations.PushoverEnabled && feed.PushoverEnabled {
  518. slog.Debug("Sending new entries to Pushover",
  519. slog.Int64("user_id", userIntegrations.UserID),
  520. slog.Int("nb_entries", len(entries)),
  521. slog.Int64("feed_id", feed.ID),
  522. )
  523. client := pushover.New(
  524. userIntegrations.PushoverUser,
  525. userIntegrations.PushoverToken,
  526. feed.PushoverPriority,
  527. userIntegrations.PushoverDevice,
  528. userIntegrations.PushoverPrefix,
  529. )
  530. if err := client.SendMessages(feed, entries); err != nil {
  531. slog.Warn("Unable to send new entries to Pushover", slog.Any("error", err))
  532. }
  533. }
  534. // Integrations that only support sending individual entries
  535. if userIntegrations.TelegramBotEnabled {
  536. for _, entry := range entries {
  537. if userIntegrations.TelegramBotEnabled {
  538. slog.Debug("Sending a new entry to Telegram",
  539. slog.Int64("user_id", userIntegrations.UserID),
  540. slog.Int64("entry_id", entry.ID),
  541. slog.String("entry_url", entry.URL),
  542. )
  543. if err := telegrambot.PushEntry(
  544. feed,
  545. entry,
  546. userIntegrations.TelegramBotToken,
  547. userIntegrations.TelegramBotChatID,
  548. userIntegrations.TelegramBotTopicID,
  549. userIntegrations.TelegramBotDisableWebPagePreview,
  550. userIntegrations.TelegramBotDisableNotification,
  551. userIntegrations.TelegramBotDisableButtons,
  552. ); err != nil {
  553. slog.Error("Unable to send entry to Telegram",
  554. slog.Int64("user_id", userIntegrations.UserID),
  555. slog.Int64("entry_id", entry.ID),
  556. slog.String("entry_url", entry.URL),
  557. slog.Any("error", err),
  558. )
  559. }
  560. }
  561. }
  562. }
  563. }