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

This commit is contained in:
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

View File

@ -32,6 +32,7 @@
#
import re
import requests
import uuid
from markdown import markdown
from json import dumps
from json import loads
@ -616,6 +617,7 @@ class NotifyMatrix(NotifyBase):
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
@ -746,7 +748,8 @@ class NotifyMatrix(NotifyBase):
# 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,
@ -1401,6 +1404,10 @@ class NotifyMatrix(NotifyBase):
# 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()