~gjabell/mfn

ref: e3e621af42a3deb6ad50e41320204010d5a389f6 mfn/README.md -rw-r--r-- 1.8 KiB View raw
e3e621afGalen Abell Ensure at least one notifier and add list command 2 months ago

mfw

A small command-line utility to send webhook notifications when Miniflux finds new RSS entries.

Example Usage

  1. Create a TOML configuration file with the following format:
server = "https://rss.example.com" # the url of the Miniflux instance
username = "myuser" # the username used to login to the Miniflux instance
password = "mypass" # the password used to login to the Miniflux instance
db_path = "/var/lib/mfw/last_entry.txt" # path where the last entry is stored
webhook_template = """
<h3>{{ .Title }}{{ if ne .Author "" }} • <i>{{ .Author }}</i>{{ end }}</h3>
{{ if ne .Content "" }}
<br/>
<blockquote>{{ printf "%.250s" .Content }}{{ if gt (len .Content) 250 }}...{{ end }}</blockquote>
{{ end }}
<br/>
<a href="{{ .URL }}">{{ .URL }}</a>""" # golang html/template-compatible template string, which will be sent as the body of the webhook
webhook_url = "https://webhooks.example.com" # the url of the webhook endpoint
  1. Ensure mwf can successfully send a webhook: mwf -t -c [path to config]

  2. Run mwf once to sync the last entry (no webhooks will be sent during the initial population): mwf -c [path to config]

  3. Periodically run mwf (for example, as a cron job) to send notifications when new entries are picked up by Miniflux: mwf -c [path to config]

Implementation

mwf uses the official Miniflux Golang client to query Miniflux for new entries. On the first run, mwf will determine the id of the most recent entry and store it in a plaintext file. On subsequent runs, mwf will only request entries posted after the latest entry, updating the latest entry id on each run. Each entry requested after the initial sync will trigger a webhook notification to the given webhook endpoint, with the body text parsed from the specified template.