Add some more debug messages to message receiving/handling

This commit is contained in:
Tulir Asokan
2018-07-01 18:41:05 +03:00
parent 8a198e67a8
commit 62b66040e7
2 changed files with 6 additions and 3 deletions
+3 -2
View File
@@ -191,12 +191,13 @@ class MatrixHandler:
return is_command, text return is_command, text
async def handle_message(self, room, sender, message, event_id): async def handle_message(self, room, sender, message, event_id):
self.log.debug(f"{sender} sent {message} to ${room}")
is_command, text = self.is_command(message) is_command, text = self.is_command(message)
sender = await User.get_by_mxid(sender).ensure_started() sender = await User.get_by_mxid(sender).ensure_started()
if not sender.relaybot_whitelisted: if not sender.relaybot_whitelisted:
self.log.debug(f"Ignoring message \"{message}\" from {sender} to {room}:"
" User is not whitelisted.")
return return
self.log.debug("Received Matrix event \"{message}\" from {sender} in {room}")
portal = Portal.get_by_mxid(room) portal = Portal.get_by_mxid(room)
if not is_command and portal and (await sender.is_logged_in() or portal.has_bot): if not is_command and portal and (await sender.is_logged_in() or portal.has_bot):
+3 -1
View File
@@ -845,7 +845,7 @@ class Portal:
await self._handle_matrix_file(type, sender_id, event_id, space, client, message, await self._handle_matrix_file(type, sender_id, event_id, space, client, message,
reply_to) reply_to)
else: else:
self.log.debug("Unhandled Matrix event: %s", message) self.log.debug(f"Unhandled Matrix event: {message}")
async def handle_matrix_pin(self, sender, pinned_message): async def handle_matrix_pin(self, sender, pinned_message):
if self.peer_type != "channel": if self.peer_type != "channel":
@@ -1279,6 +1279,8 @@ class Portal:
duplicate_found = self.is_duplicate(evt, (temporary_identifier, tg_space)) duplicate_found = self.is_duplicate(evt, (temporary_identifier, tg_space))
if duplicate_found: if duplicate_found:
mxid, other_tg_space = duplicate_found mxid, other_tg_space = duplicate_found
self.log.debug(f"Ignoring message {evt.id}@{tg_space} (src {source.tgid}) "
f"as it was already handled (in space {other_tg_space})")
if tg_space != other_tg_space: if tg_space != other_tg_space:
self.db.add( self.db.add(
DBMessage(tgid=evt.id, mx_room=self.mxid, mxid=mxid, tg_space=tg_space)) DBMessage(tgid=evt.id, mx_room=self.mxid, mxid=mxid, tg_space=tg_space))