Skip to content

Commit

Permalink
Matrix Long Lived Token: Don't logout, and use UUIDv4 for transaction…
Browse files Browse the repository at this point in the history
…Ids (#1249)
  • Loading branch information
voc0der authored Nov 30, 2024
1 parent 9e301df commit c49e212
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apprise/plugins/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#
import re
import requests
import uuid
from markdown import markdown
from json import dumps
from json import loads
Expand Down Expand Up @@ -616,6 +617,7 @@ def _send_server_notification(self, body, title='',

if self.access_token is None and self.password and not self.user:
self.access_token = self.password
self.transaction_id = uuid.uuid4()

if self.access_token is None:
# We need to register
Expand Down Expand Up @@ -746,7 +748,8 @@ def _send_server_notification(self, body, title='',

# Increment the transaction ID to avoid future messages being
# recognized as retransmissions and ignored
if self.version == MatrixVersion.V3:
if self.version == MatrixVersion.V3 \
and self.access_token != self.password:
self.transaction_id += 1
self.store.set(
'transaction_id', self.transaction_id,
Expand Down Expand Up @@ -1401,6 +1404,10 @@ def __del__(self):
# re-use our credentials with
return

if self.access_token is not None \
and self.access_token == self.password and not self.user:
return

try:
self._logout()

Expand Down

0 comments on commit c49e212

Please sign in to comment.