Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Ntfy.sh notification support #161

Closed
wants to merge 5 commits into from
Closed

Conversation

tom-keim
Copy link

@tom-keim tom-keim commented Aug 19, 2024

Ntfy,sh is a selfhostable notification service. As I use ntfy.sh for notifications about my homelab, I missed the integration in vaultwarden-backup as that only supports PING and MAIL.

This PR will add Ntfy,sh support, it supports 3 different authentication modes: No authentication, username + password and token based authentication.

Also the priority of the notifications are configurable, so that a backup failure results in a more urgent notification on the subscribed clients.

@ttionya
Copy link
Owner

ttionya commented Sep 3, 2024

Thank you for your contribution.

Recently, I have been engrossed in the game "Black Myth: Wukong". Now that I have completed it, I just saw this PR and apologize for the delay.

Ntfy.sh is an excellent push notification system. The existing environment variables PING_URL, PING_URL_WHEN_SUCCESS, and PING_URL_WHEN_FAILURE already provide minimal support.

Ntfy.sh supports GET requests, as detailed in the documentation. If the environment variable PING_URL_WHEN_SUCCESS: 'ntfy.sh/mywebhook/publish?message=Webhook+triggered&priority=high&tags=warning,skull&auth=xxx' is configured, a PING message will be sent to this address when the backup is successful. The minimal support is due to the need for users to set the message themselves, rather than using content provided by the tool.

Ntfy.sh offers a wide range of features, and I do not believe it is wise to provide an environment variable for each feature. The PR added 10 new environment variables, and in the future, we might need to add environment variables for setting X-Tags, X-Email, etc. This requires the tool to continuously adapt to specific notification tools, which is what I am trying to avoid.

@ttionya
Copy link
Owner

ttionya commented Sep 3, 2024

My current plan is to add corresponding curl options environment variables for the existing PING_URL prefixed environment variables, such as PING_URL_CURL_OPTIONS. This way, users can configure them as needed.

For Ntfy.sh, you can set PING_URL_CURL_OPTIONS: '-H "X-Priority: high" -H "X-Tags: warning,skull" -H "Authorization: Bearer xxx"'. It is equivalent to the GET request mentioned earlier.

Additionally, I will add placeholders for these environment variables, such as %{title} and %{content} in PING_URL and PING_URL_CURL_OPTIONS, which can be replaced with actual titles and content.

This approach allows for more functionality with fewer environment variables and avoids continuous adaptation to specific tools, similar to the MAIL_SMTP_VARIABLES environment variable.

I will add the above features as soon as possible.

@tom-keim
Copy link
Author

tom-keim commented Sep 3, 2024

Thank you for your reply, that indeed sounds like a better option.

If I can help in any way please let me know.

I'll close this PR

@ttionya
Copy link
Owner

ttionya commented Sep 7, 2024

Released v1.21.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants