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

pull/1253/head
voc0der 2024-11-30 22:11:19 +00:00 committed by GitHub
parent 9e301df438
commit c49e2127c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 1 deletions

View File

@ -32,6 +32,7 @@
# #
import re import re
import requests import requests
import uuid
from markdown import markdown from markdown import markdown
from json import dumps from json import dumps
from json import loads from json import loads
@ -616,6 +617,7 @@ class NotifyMatrix(NotifyBase):
if self.access_token is None and self.password and not self.user: if self.access_token is None and self.password and not self.user:
self.access_token = self.password self.access_token = self.password
self.transaction_id = uuid.uuid4()
if self.access_token is None: if self.access_token is None:
# We need to register # We need to register
@ -746,7 +748,8 @@ class NotifyMatrix(NotifyBase):
# Increment the transaction ID to avoid future messages being # Increment the transaction ID to avoid future messages being
# recognized as retransmissions and ignored # 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.transaction_id += 1
self.store.set( self.store.set(
'transaction_id', self.transaction_id, 'transaction_id', self.transaction_id,
@ -1401,6 +1404,10 @@ class NotifyMatrix(NotifyBase):
# re-use our credentials with # re-use our credentials with
return return
if self.access_token is not None \
and self.access_token == self.password and not self.user:
return
try: try:
self._logout() self._logout()