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

Matrix Long Lived Token: Don't logout, and use UUIDv4 for transactionIds #1249

Merged
merged 16 commits into from
Nov 30, 2024

Conversation

voc0der
Copy link
Contributor

@voc0der voc0der commented Nov 29, 2024

Description:

Related issue (if applicable):
The previous PR seems to work for the first message of each channel. #1236 However, after sending one message, it logs me out and stops working.

In addition to that, the existing cache system was designed to login, then use that session until apprise is shut down. Then log in again, get a new session and start from 0. There appears to be a different storage option, but it's not clear from the code exactly if it would work if the container is restarted or docker compose down. Additionally, it seems 20d is the default max cache length. Which infinite is what we need.

On with the changes:

  • One we don't want it to ever log the token out.
  • Two, a token like this transcends active memory, so it makes sense to use a UUIDv4 here. In the Matrix v3 spec it recommends either that or the incrementer, which is what we have. See https://spec.matrix.org/v1.12/client-server-api/#transaction-identifiers . The current implementation is just an growing integer.

This version I have running just fine all day on my build, mounting it overtop the apprise-api default matrix.py.

It is possible, but incredibly unlikely that a UUIDv4 could repeat within the life of a session. https://jhall.io/archive/2021/05/19/what-are-the-odds/ and when matrix-synapse resets, I bet it forgets all the endpoints associated with a token making it that much more unlikely that anyone would ever see this happen.

If I'm totally wrong about how the storage is done and it should be done, I'd like to know more. It seemed like it wasn't going to work that way.

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

#encrypted
apprise -t "Test Title" -b "Test Message" \
  matrixs://[email protected]?v=token

#unencrypted
apprise -t "Test Title" -b "Test Message" \
  matrix://[email protected]?v=token

where `mct_xxxxxxxxxxxxxxxx` is your header authorization bearer token for matrix.

@voc0der
Copy link
Contributor Author

voc0der commented Nov 29, 2024

So, this works, passes flake8. Wont pass another check citing that self.transaction_id is not an integer. Which, fine, it's declared as 0 in the beginning.

Open to suggestions on how to get it to pass the test cleanly.

Edit.
Nevermind, I guess I'm an idiot. Seems good.

Copy link

codecov bot commented Nov 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.37%. Comparing base (9e301df) to head (d1c806d).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1249   +/-   ##
=======================================
  Coverage   99.37%   99.37%           
=======================================
  Files         148      148           
  Lines       20641    20645    +4     
  Branches     3674     3675    +1     
=======================================
+ Hits        20511    20515    +4     
  Misses        121      121           
  Partials        9        9           

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

@voc0der voc0der changed the title Matrix: Don't logout when using long lived tokens Matrix: Don't logout when using long lived tokens and use UUID for transactionIds Nov 29, 2024
@voc0der voc0der changed the title Matrix: Don't logout when using long lived tokens and use UUID for transactionIds Matrix Long Lived Token: Don't logout, and use UUID for transactionIds Nov 29, 2024
@voc0der voc0der changed the title Matrix Long Lived Token: Don't logout, and use UUID for transactionIds Matrix Long Lived Token: Don't logout, and use UUIDv4 for transactionIds Nov 30, 2024
@caronc caronc merged commit c49e212 into caronc:master Nov 30, 2024
13 checks passed
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.

2 participants