Outgoing replies to replies

This commit is contained in:
Andrew Ferrazzutti 2022-04-06 14:33:01 -04:00
parent f682edb719
commit ae9fd46bc8
1 changed files with 9 additions and 2 deletions

View File

@ -29,6 +29,7 @@ from mautrix.util.formatter import (
from mautrix.util.logging import TraceLogger from mautrix.util.logging import TraceLogger
from ..kt.types.bson import Long from ..kt.types.bson import Long
from ..kt.types.chat import KnownChatType
from ..kt.types.chat.attachment import ReplyAttachment, MentionStruct from ..kt.types.chat.attachment import ReplyAttachment, MentionStruct
from ..kt.client.types import TO_MSGTYPE_MAP from ..kt.client.types import TO_MSGTYPE_MAP
@ -98,6 +99,10 @@ async def matrix_to_kakaotalk(
) )
content.trim_reply_fallback() content.trim_reply_fallback()
src_converted = await matrix_to_kakaotalk(src_event.content, room_id, log, intent, skip_reply=True) 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( reply_to = ReplyAttachment(
# NOTE mentions will be merged into this later # NOTE mentions will be merged into this later
# TODO Set this for emoticon reply, but must first support them # 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 # 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 # But then, the reply object must be an intersection of a ReplyAttachment and something else
#attach_type=TO_MSGTYPE_MAP.get(content.msgtype), #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_logId=message.ktid,
src_mentions=src_converted.mentions or [], src_mentions=src_converted.mentions or [],
src_message=src_converted.text, src_message=src_converted.text,
src_type=TO_MSGTYPE_MAP[src_event.content.msgtype], src_type=src_type,
src_userId=src_kt_sender, src_userId=src_kt_sender,
) )
else: else:
@ -137,7 +144,7 @@ async def matrix_to_kakaotalk(
user_id=ktid, user_id=ktid,
)) ))
mention.at.append(at) mention.at.append(at)
mentions = list(mentions_by_user.values()) mentions = list(mentions_by_user.values()) if mentions_by_user else None
else: else:
text = content.body text = content.body
mentions = None mentions = None