From ae9fd46bc8533c8ec2561a1232a6a63bab08e18b Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Wed, 6 Apr 2022 14:33:01 -0400 Subject: [PATCH] Outgoing replies to replies --- matrix_appservice_kakaotalk/formatter/from_matrix.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/matrix_appservice_kakaotalk/formatter/from_matrix.py b/matrix_appservice_kakaotalk/formatter/from_matrix.py index db04449..a49aa7a 100644 --- a/matrix_appservice_kakaotalk/formatter/from_matrix.py +++ b/matrix_appservice_kakaotalk/formatter/from_matrix.py @@ -29,6 +29,7 @@ from mautrix.util.formatter import ( from mautrix.util.logging import TraceLogger from ..kt.types.bson import Long +from ..kt.types.chat import KnownChatType from ..kt.types.chat.attachment import ReplyAttachment, MentionStruct from ..kt.client.types import TO_MSGTYPE_MAP @@ -98,6 +99,10 @@ async def matrix_to_kakaotalk( ) content.trim_reply_fallback() src_converted = await matrix_to_kakaotalk(src_event.content, room_id, log, intent, skip_reply=True) + if src_event.content.relates_to.rel_type == RelationType.REPLY: + src_type = KnownChatType.REPLY + else: + src_type = TO_MSGTYPE_MAP[src_event.content.msgtype] reply_to = ReplyAttachment( # NOTE mentions will be merged into this later # TODO Set this for emoticon reply, but must first support them @@ -105,10 +110,12 @@ async def matrix_to_kakaotalk( # TODO If replying with media works, must set type AND all attachment properties # But then, the reply object must be an intersection of a ReplyAttachment and something else #attach_type=TO_MSGTYPE_MAP.get(content.msgtype), + # TODO Confirm why official client sets this to 0, and whether this should be left as None instead + attach_type=0, src_logId=message.ktid, src_mentions=src_converted.mentions or [], src_message=src_converted.text, - src_type=TO_MSGTYPE_MAP[src_event.content.msgtype], + src_type=src_type, src_userId=src_kt_sender, ) else: @@ -137,7 +144,7 @@ async def matrix_to_kakaotalk( user_id=ktid, )) mention.at.append(at) - mentions = list(mentions_by_user.values()) + mentions = list(mentions_by_user.values()) if mentions_by_user else None else: text = content.body mentions = None