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

RocketChat Token Support #1060

Merged
merged 1 commit into from
Apr 13, 2024
Merged

RocketChat Token Support #1060

merged 1 commit into from
Apr 13, 2024

Conversation

caronc
Copy link
Owner

@caronc caronc commented Feb 10, 2024

Description:

Related issue (if applicable): #210

Added token support to the ?mode= list. The syntax is:

  • {schema}://{user}:{token}@{host}:{port}/{targets}
  • {schema}://{user}:{token}@{host}/{targets}

Note: {schema} is either rocket or rockets

this is similar to {schema}://{user}:{password}@{host}:{port}/{targets}. Apprise tries to detect if it was a {password} or {token} based on it's length. If the value specified is >32 characters, then it assumes ?mode=token, otherwise it will use ?mode=basic.

You can always specific the mode=<val> to enforce what you meant.

If you specify a {user}/{token}, then authentication HTTP requests are skipped and the X-User-Id and X-Auth-Token are pre-populated in the headers in advance.

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

Testing

Anyone can help test this source code as follows:

# Create a virtual environment to work in as follows:
python3 -m venv apprise

# Change into our new directory
cd apprise

# Activate our virtual environment
source bin/activate

# Install the branch
pip install git+https://github.com/caronc/apprise.git@210-rocket-token-support

# Test out the changes with the following command:
apprise -t "Test Title" -b "Test Message" \
  "rocket://user:token@rocket.server?mode=token"

@caronc
Copy link
Owner Author

caronc commented Feb 10, 2024

This branch needs testing; hopefully @portalzine or @xgaia can give it a shot (instructions above) and let me know?

@codecov-commenter
Copy link

codecov-commenter commented Feb 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (31a4f2e) 99.27% compared to head (a17cebc) 99.27%.
Report is 1 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1060   +/-   ##
=======================================
  Coverage   99.27%   99.27%           
=======================================
  Files         135      135           
  Lines       17600    17611   +11     
  Branches     3592     3596    +4     
=======================================
+ Hits        17472    17483   +11     
  Misses        119      119           
  Partials        9        9           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@portalzine
Copy link

Currently running it from the apprise-api. Will do a fresh pure branch install later this week and let you know ...

@caronc caronc merged commit 33c7569 into master Apr 13, 2024
12 checks passed
@caronc caronc deleted the 210-rocket-token-support branch April 14, 2024 15:19
@portalzine
Copy link

portalzine commented Apr 16, 2024

Tested this with the latest release and I am always getting:
Failed to send Rocket.Chat token:notification: Channel/RoomId is wrong format, or missing from server., error=400.
Tried varies formats:

  1. rockets://userid:token@chat.myhost.com/@username?mode=token
  2. rockets://userid:token@chat.myhost.com/#channel?mode=token
  3. rockets://userid:token@chat.myhost.com?mode=token&channel=#channel

3 - sends no error message, but never sends the notification itself (no errors in the apprise logs).

Token is fine and channel exists.

The workaround using the api directly works fine json://chat.myhost.com/api/v1/chat.postMessage, which means that there is something else.

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