-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
feat(alerting): add email and click action to ntfy provider #778
base: master
Are you sure you want to change the base?
Conversation
There are also other properties supported by ntfy, which are not implemented yet:
https://docs.ntfy.sh/publish/#publish-as-json There are also cache and firebase supported using the http request instead of JSON. That and other not implemented properties could be worked around via the custom provider for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but could you create a few tests?
@stendler WRT |
Sorry, I have not updated that comment but only the PR summary:
What kind of tests do you want to see here? For There does not seem to be a test for the request headers there yet. So either a test with a server receiving the request is needed or a refactor of the Send method into a buildRequest to be able to test for the headers. Which of these options do you think are best? |
@stendler A new case for |
@TwiN I've now added tests for the json properties and also tests for verifying the request headers from the Send function using httptest. |
README.md
Outdated
| `alerting.ntfy.firebase` | Whether messages should be delivered via firebase. [ntfy.sh defaults to true](https://docs.ntfy.sh/publish/#disable-firebase) | `""` | | ||
| `alerting.ntfy.cache` | Whether message should be cached server side. [ntfy.sh defaults to true](https://docs.ntfy.sh/publish/#message-caching) | `""` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm almost wondering if it would make more sense to rename these to disable-firebase
and disable-cache
respectively so that we can have both of them just be bool
instead of *bool
.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that sounds good. This would also make these config options a bit more self-explanatory.
Will do that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TwiN hmm, now that I've slept over this: there is a niche edge case here. Omitting to set the headers (which I do here if disabled) will result in the server default. Which is enabled for ntfy.sh, but might be different for other instances (if they support this at all).
So either
- always set the headers explicitly, defaulting to enabled if this config is missing
- only set explicitly if it should be disabled and omit otherwise, falling back to the server default (current implemented behavior)
- use nil to use the server default and set explicitly if the user specifies so in the config
The first two can avoid the pointer, while the latter option needs it to determine if this option is set in the config or not.
I would tend to the last option for more flexibility, although it might be unlikely to matter in practice.
If you definitely want to avoid the pointer, that's fine by me as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point.
Am I correct in my understanding that for firebase to work in the first place, multiple configurations on ntfy's side must be set, and even if firebase is enabled through Gatus, without these configurations on ntfy's side, firebase will not work anyways?
If so, I think we can assume the intent of the user without needing a pointer:
- If
disable-firebase
is set tofalse
(default), then theFirebase
header is present with the valueyes
and will work BUT ONLY if the user configured firebase to work on ntfy, which is the behavior of the current implementation - If
disable-firebase
is set totrue
, then theFirebase
header is set tono
, which the user would only explicitly setdisable-firebase
totrue
if their ntfy configuration had firebase configured and they didn't want this Gatus alert to use Firebase.
Does that make sense?
P.S. This assumes that a request with Firebase: yes
won't return a 4xx error if the ntfy configuration doesn't have Firebase on it but will instead fail silently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, your understanding is correct. For self-hosted, the admin needs to explicitly configure it (it apparently even requires a modified android app).
I've also checked that:
- If not configured, but the header is set, it is silently ignored
- If the header is not set, regardless of server configuration, it is set to a hard-coded default of true - so my assumption, that the default might differ on other instances, was false
With the naming changed to disabled-firebase
, I would suggest omitting the header if the config is omitted or set to false. Especially, since enabled is the hard-coded default on the server anyway.
I've now updated this PR this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @TwiN in case you missed my last message
This avoids the need for a pointer, as omitting these bools in the config defaults to false and omitting to set these headers will use the server's default - which is enabled on ntfy.sh
Summary
Adds the email and click properties to the ntfy provider.
Documentation to publishing on ntfy via JSON: https://docs.ntfy.sh/publish/#publish-as-json
Edit: Now also adds the properties
firebase
andcache
, which currently cannot be defined in JSON but as http headers (binwiederhier/ntfy#1119).Checklist
README.md
, if applicable.