mirror of
https://github.com/matrix-org/pantalaimon.git
synced 2024-10-01 03:35:38 -04:00
client: Make the room messages callback more specific.
This commit is contained in:
parent
1db93a731f
commit
71e672a431
@ -24,8 +24,9 @@ from jsonschema import Draft4Validator, FormatChecker, validators
|
|||||||
from nio import (AsyncClient, ClientConfig, EncryptionError, KeysQueryResponse,
|
from nio import (AsyncClient, ClientConfig, EncryptionError, KeysQueryResponse,
|
||||||
KeyVerificationEvent, KeyVerificationKey, KeyVerificationMac,
|
KeyVerificationEvent, KeyVerificationKey, KeyVerificationMac,
|
||||||
KeyVerificationStart, LocalProtocolError, MegolmEvent,
|
KeyVerificationStart, LocalProtocolError, MegolmEvent,
|
||||||
RoomEncryptedEvent, RoomMessage, SyncResponse,
|
RoomEncryptedEvent, SyncResponse,
|
||||||
RoomContextError)
|
RoomContextError, RoomMessageText, RoomMessageMedia,
|
||||||
|
RoomEncryptedMedia, RoomTopicEvent, RoomNameEvent)
|
||||||
from nio.crypto import Sas
|
from nio.crypto import Sas
|
||||||
from nio.store import SqliteStore
|
from nio.store import SqliteStore
|
||||||
|
|
||||||
@ -144,7 +145,8 @@ class PanClient(AsyncClient):
|
|||||||
)
|
)
|
||||||
self.add_event_callback(
|
self.add_event_callback(
|
||||||
self.store_message_cb,
|
self.store_message_cb,
|
||||||
RoomMessage
|
(RoomMessageText, RoomMessageMedia, RoomEncryptedMedia,
|
||||||
|
RoomTopicEvent, RoomNameEvent)
|
||||||
)
|
)
|
||||||
self.key_verificatins_tasks = []
|
self.key_verificatins_tasks = []
|
||||||
self.key_request_tasks = []
|
self.key_request_tasks = []
|
||||||
|
@ -15,7 +15,8 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import tantivy
|
import tantivy
|
||||||
from nio import RoomMessageText, RoomNameEvent, RoomTopicEvent
|
from nio import (RoomMessageText, RoomNameEvent, RoomTopicEvent,
|
||||||
|
RoomMessageMedia, RoomEncryptedMedia)
|
||||||
|
|
||||||
|
|
||||||
def sanitize_room_id(room_id):
|
def sanitize_room_id(room_id):
|
||||||
@ -118,6 +119,8 @@ class Index:
|
|||||||
|
|
||||||
if isinstance(event, RoomMessageText):
|
if isinstance(event, RoomMessageText):
|
||||||
doc.add_text(self.body_field, event.body)
|
doc.add_text(self.body_field, event.body)
|
||||||
|
elif isinstance(event, (RoomMessageMedia, RoomEncryptedMedia)):
|
||||||
|
doc.add_text(self.body_field, event.body)
|
||||||
elif isinstance(event, RoomNameEvent):
|
elif isinstance(event, RoomNameEvent):
|
||||||
doc.add_text(self.name_field, event.name)
|
doc.add_text(self.name_field, event.name)
|
||||||
elif isinstance(event, RoomTopicEvent):
|
elif isinstance(event, RoomTopicEvent):
|
||||||
|
Loading…
Reference in New Issue
Block a user