Add backlog message class.

This commit is contained in:
poljar (Damir Jelić) 2018-02-12 13:22:48 +01:00
parent aa625f0962
commit dbf7df2e84
2 changed files with 27 additions and 3 deletions

View file

@ -431,6 +431,25 @@ class MatrixRedactMessage(MatrixGenericMessage):
)
class MatrixBacklogMessage(MatrixGenericMessage):
def __init__(self, client, room_id, token, limit):
self.room_id = room_id
data = {
"room_id": self.room_id,
"start_token": token,
"direction": "b",
"limit": limit
}
MatrixGenericMessage.__init__(
self,
MessageType.ROOM_MSG,
client.room_get_messages,
data
)
class MatrixUser:
def __init__(self, name, display_name):
self.name = name # type: str

View file

@ -28,7 +28,8 @@ from matrix.api import (
MatrixMessage,
MessageType,
MatrixTopicMessage,
MatrixRedactMessage
MatrixRedactMessage,
MatrixBacklogMessage
)
from matrix.utils import key_from_value, tags_from_line_data
from matrix.plugin_options import DebugType
@ -110,8 +111,12 @@ def matrix_fetch_old_messages(server, room_id):
if not prev_batch:
return
message = MatrixMessage(server, OPTIONS, MessageType.ROOM_MSG,
room_id=room_id, token=prev_batch)
message = MatrixBacklogMessage(
server.client,
room_id=room_id,
token=prev_batch,
limit=OPTIONS.backlog_limit
)
server.send_or_queue(message)