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 Zulip 401 when bot name contains a dash #581

Merged
merged 1 commit into from
May 2, 2022
Merged

Fix Zulip 401 when bot name contains a dash #581

merged 1 commit into from
May 2, 2022

Conversation

c-w
Copy link
Contributor

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

Description

Sending a message to Zulip failed with my setup:

> docker run --entrypoint=apprise --rm caronc/apprise -vv -t "Test title" -b "Test body" "zulip://some-name@someorganization.zulipchat.com/<token>/Alerts"
2022-05-02 14:14:33,816 - INFO - Notifying 1 service(s) asynchronously.
2022-05-02 14:14:34,047 - WARNING - Failed to send Zulip notification to Alerts: Unauthorized - Invalid Token., error=401.

The error is caused because the regex used to parse the bot name only considered the part before the first dash leading to an invalid user name being sent in the request's basic auth.

This pull request fixes the issue by making the bot name regex more permissive and manually stripping off the -bot suffix instead of doing it in the regex.

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • No lint errors (use flake8)
  • 100% test coverage

@codecov-commenter
Copy link

codecov-commenter commented May 2, 2022

Codecov Report

Merging #581 (7633e1b) into master (fd0cb3f) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #581   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          109       109           
  Lines        14094     14099    +5     
  Branches      2637      2637           
=========================================
+ Hits         14094     14099    +5     
Impacted Files Coverage Δ
apprise/plugins/NotifyZulip.py 100.00% <100.00%> (ø)
apprise/utils.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fd0cb3f...7633e1b. Read the comment docs.

@caronc
Copy link
Owner

caronc commented May 2, 2022

Thank you for this PR! 🚀

@caronc caronc merged commit af2919f into caronc:master May 2, 2022
@c-w c-w deleted the fix-zulip-botname-dash branch May 2, 2022 16:49
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