Skip to content

Commit 6b3b17c

Browse files
committed
Use target event thread parent if event is already in thread
Previously set_thread_parent didn't work correctly if you passed an event that's already in a thread and not the root.
1 parent fa9f9fd commit 6b3b17c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

mautrix/types/event/message.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ def set_thread_parent(
112112
self.relates_to.event_id = (
113113
thread_parent if isinstance(thread_parent, str) else thread_parent.event_id
114114
)
115+
if isinstance(thread_parent, MessageEvent) and isinstance(
116+
thread_parent.content, BaseMessageEventContentFuncs
117+
):
118+
self.relates_to.event_id = (
119+
thread_parent.content.get_thread_parent() or self.relates_to.event_id
120+
)
115121
if not disable_reply_fallback:
116122
self.set_reply(last_event_in_thread or thread_parent, **kwargs)
117123
self.relates_to.is_falling_back = True

0 commit comments

Comments
 (0)