caronc / apprise

Apprise - Push Notifications that work with just about every platform!
https://hub.docker.com/r/caronc/apprise
BSD 2-Clause "Simplified" License
11.7k stars 410 forks source link

RocketChat Token Support #1060

Closed caronc closed 5 months ago

caronc commented 7 months ago

Description:

Related issue (if applicable): #210

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

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

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 commented 7 months ago

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

codecov-commenter commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

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

Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

portalzine commented 7 months ago

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

portalzine commented 5 months ago

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.