Skip to content

Commit

Permalink
Adjust set_thread_parent parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Apr 21, 2022
1 parent ed02e71 commit e1a4c2a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v0.16.3 (2022-04-21)

* Changed `set_thread_parent` to have an explicit option for disabling the
thread-as-reply fallback.

## v0.16.2 (2022-04-21)

* Added `get_thread_parent` and `set_thread_parent` helper methods for `MessageEventContent`.
Expand Down
2 changes: 1 addition & 1 deletion mautrix/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.16.2"
__version__ = "0.16.3"
__author__ = "Tulir Asokan <tulir@maunium.net>"
__all__ = [
"api",
Expand Down
9 changes: 4 additions & 5 deletions mautrix/types/event/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,17 @@ def set_reply(self, reply_to: Union[EventID, "MessageEvent"], **kwargs) -> None:
def set_thread_parent(
self,
thread_parent: Union[EventID, "MessageEvent"],
reply_to: Union[EventID, "MessageEvent", None] = None,
last_event_in_thread: Union[EventID, "MessageEvent", None] = None,
disable_reply_fallback: bool = False,
**kwargs,
) -> None:
self.relates_to.rel_type = RelationType.THREAD
self.relates_to.event_id = (
thread_parent if isinstance(thread_parent, str) else thread_parent.event_id
)
if reply_to is None:
self.set_reply(thread_parent, **kwargs)
if not disable_reply_fallback:
self.set_reply(last_event_in_thread or thread_parent, **kwargs)
self.relates_to.is_falling_back = True
else:
self.set_reply(reply_to, **kwargs)

def set_edit(self, edits: Union[EventID, "MessageEvent"]) -> None:
self.relates_to.rel_type = RelationType.REPLACE
Expand Down

0 comments on commit e1a4c2a

Please sign in to comment.