Disallow sending of multiple backlog messages in parallel.
This commit is contained in:
parent
0fba3016ee
commit
6d4f69e3a2
3 changed files with 15 additions and 8 deletions
|
@ -108,6 +108,10 @@ def hook_commands():
|
|||
|
||||
def matrix_fetch_old_messages(server, room_id):
|
||||
room = server.rooms[room_id]
|
||||
|
||||
if room.backlog_pending:
|
||||
return
|
||||
|
||||
prev_batch = room.prev_batch
|
||||
|
||||
if not prev_batch:
|
||||
|
@ -119,6 +123,7 @@ def matrix_fetch_old_messages(server, room_id):
|
|||
token=prev_batch,
|
||||
limit=OPTIONS.backlog_limit
|
||||
)
|
||||
room.backlog_pending = True
|
||||
|
||||
server.send_or_queue(message)
|
||||
|
||||
|
|
|
@ -343,6 +343,7 @@ class MatrixBacklogEvent(MatrixEvent):
|
|||
message.prnt(room, buf, tags)
|
||||
|
||||
room.prev_batch = self.end_token
|
||||
room.backlog_pending = False
|
||||
|
||||
|
||||
class MatrixSyncEvent(MatrixEvent):
|
||||
|
|
|
@ -25,14 +25,15 @@ class MatrixRoom:
|
|||
def __init__(self, room_id):
|
||||
# type: (str) -> None
|
||||
# yapf: disable
|
||||
self.room_id = room_id # type: str
|
||||
self.alias = room_id # type: str
|
||||
self.topic = "" # type: str
|
||||
self.topic_author = "" # type: str
|
||||
self.topic_date = None # type: datetime.datetime
|
||||
self.prev_batch = "" # type: str
|
||||
self.users = dict() # type: Dict[str, MatrixUser]
|
||||
self.encrypted = False # type: bool
|
||||
self.room_id = room_id # type: str
|
||||
self.alias = room_id # type: str
|
||||
self.topic = "" # type: str
|
||||
self.topic_author = "" # type: str
|
||||
self.topic_date = None # type: datetime.datetime
|
||||
self.prev_batch = "" # type: str
|
||||
self.users = dict() # type: Dict[str, MatrixUser]
|
||||
self.encrypted = False # type: bool
|
||||
self.backlog_pending = False # type: bool
|
||||
# yapf: enable
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue