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

Fix apprise integration for Zulip Streams #1604

Merged
merged 4 commits into from
May 10, 2022
Merged

Fix apprise integration for Zulip Streams #1604

merged 4 commits into from
May 10, 2022

Conversation

c-w
Copy link
Contributor

@c-w c-w commented May 2, 2022

Description

Currently it's impossible to send a notification from uptime-kuma to a Zulip stream via the apprise integration. This is because some apprise backends (including messaging a Zulip stream) fail if the notification title isn't included in the request:

> docker run --entrypoint=apprise --rm caronc/apprise -vv -b "body" "zulip://<bot>@<organization>/<token>/<stream>"
2022-05-02 15:19:04,118 - INFO - Notifying 1 service(s) asynchronously.
2022-05-02 15:19:04,416 - WARNING - Failed to send Zulip notification to <stream>: Bad Request - Unsupported Parameters., error=400.

If we add the argument -t "title" the notification is sent correctly:

> docker run --entrypoint=apprise --rm caronc/apprise -vv -b "body" "zulip://<bot>@<organization>/<token>/<stream>" -t "title"
2022-05-02 15:19:51,545 - INFO - Notifying 1 service(s) asynchronously.
2022-05-02 15:19:51,832 - INFO - Sent Zulip notification to <stream>.

To fix this scenario, this pull request adds an environment variable APPRISE_NOTIFICATION_TITLE that can be used to include the title argument in the call to apprise.

In an ideal world, the title would be derived from the data that's passed into the send function, but this would be a breaking change. The approach proposed in this pull request is fully backwards compatible as a user of uptime-kuma must explicitly opt-in to the new behavior by setting the new environment variable.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and tested it
  • I have commented my code, particularly in hard-to-understand areas (including JSDoc for methods)
  • My changes generate no new warnings
  • My code needed automated testing. I have added them (this is optional task)

Copy link
Contributor

@gaby gaby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this needs a default value of some sort. Else its not fixing anything.

Maybe the hostname or IP of uptime-kuma.

@c-w
Copy link
Contributor Author

c-w commented May 3, 2022

@gaby I'm totally open to adding a default, however I need to point out that it would be a backwards incompatible change as any deployment of uptime-kuma that uses an apprise backend which doesn't require a title (e.g. Zulip direct messages) will have the behavior changed. I read in the contributing guide here that backwards incompatible changes won't be merged, which is why I went with the opt-in path in this PR. I'm not familiar with all the apprise backends (I just use it for Zulip) so I can't say how prevalent the title requirement actually is. Let me know what you think.

@gaby
Copy link
Contributor

gaby commented May 3, 2022

@gaby I'm totally open to adding a default, however I need to point out that it would be a backwards incompatible change as any deployment of uptime-kuma that uses an apprise backend which doesn't require a title (e.g. Zulip direct messages) will have the behavior changed. I read in the contributing guide here that backwards incompatible changes won't be merged, which is why I went with the opt-in path in this PR. I'm not familiar with all the apprise backends (I just use it for Zulip) so I can't say how prevalent the title requirement actually is. Let me know what you think.

Yeah, I see what you mean now. 👍🏻 looks good to me.

@c-w
Copy link
Contributor Author

c-w commented May 3, 2022

Thanks for the review @gaby. What's the process for getting something merged and published? Anything I can help with?

@gaby
Copy link
Contributor

gaby commented May 3, 2022

Thanks for the review @gaby. What's the process for getting something merged and published? Anything I can help with?

Basically, final review and merge is all done by @louislam

@louislam
Copy link
Owner

louislam commented May 6, 2022

Environment Variable is not encouraged in the project. (https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md)

In this case, if a user want to use Zulip Streams, they need to add the env variable and restart the Uptime Kuma instance in order to activate it.

Also users can setup multiple Apprise notifications, it will affect all Apprise notifications.

My suggestion would be add an optional field title in Apprise setup dialog form in the frontend.

if (title is undefined || title is empty string) {
   call apprise without title (original call)
} else {
   call apprise with title (new)
}

@c-w
Copy link
Contributor Author

c-w commented May 7, 2022

Thanks for the feedback @louislam. I moved the title configuration from the environment variable to a new input field in the UI in b680371. See below for a screenshot:

Screenshot of title in apprise setup UI

I also validated that the alert sends correctly to a stream in my Zulip instance:

Screenshot of notification in Zulip stream

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.

3 participants