From 71e672a43196c56149028f3ce0ffaf2eca397745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Mon, 10 Jun 2019 15:52:22 +0200 Subject: [PATCH] client: Make the room messages callback more specific. --- pantalaimon/client.py | 8 +++++--- pantalaimon/index.py | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pantalaimon/client.py b/pantalaimon/client.py index ae670d1..facf8f5 100644 --- a/pantalaimon/client.py +++ b/pantalaimon/client.py @@ -24,8 +24,9 @@ from jsonschema import Draft4Validator, FormatChecker, validators from nio import (AsyncClient, ClientConfig, EncryptionError, KeysQueryResponse, KeyVerificationEvent, KeyVerificationKey, KeyVerificationMac, KeyVerificationStart, LocalProtocolError, MegolmEvent, - RoomEncryptedEvent, RoomMessage, SyncResponse, - RoomContextError) + RoomEncryptedEvent, SyncResponse, + RoomContextError, RoomMessageText, RoomMessageMedia, + RoomEncryptedMedia, RoomTopicEvent, RoomNameEvent) from nio.crypto import Sas from nio.store import SqliteStore @@ -144,7 +145,8 @@ class PanClient(AsyncClient): ) self.add_event_callback( self.store_message_cb, - RoomMessage + (RoomMessageText, RoomMessageMedia, RoomEncryptedMedia, + RoomTopicEvent, RoomNameEvent) ) self.key_verificatins_tasks = [] self.key_request_tasks = [] diff --git a/pantalaimon/index.py b/pantalaimon/index.py index fb3db80..4047028 100644 --- a/pantalaimon/index.py +++ b/pantalaimon/index.py @@ -15,7 +15,8 @@ import datetime import tantivy -from nio import RoomMessageText, RoomNameEvent, RoomTopicEvent +from nio import (RoomMessageText, RoomNameEvent, RoomTopicEvent, + RoomMessageMedia, RoomEncryptedMedia) def sanitize_room_id(room_id): @@ -118,6 +119,8 @@ class Index: if isinstance(event, RoomMessageText): 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): doc.add_text(self.name_field, event.name) elif isinstance(event, RoomTopicEvent):