integration.go 22 KB

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