No need for origin_*body Event keys

Also fixes lack of original message text when
replying to non-message events.
This commit is contained in:
miruka 2020-05-20 06:37:50 -04:00
parent b09b3b990b
commit 66f9a17111
2 changed files with 13 additions and 17 deletions

View File

@ -426,15 +426,19 @@ class MatrixClient(nio.AsyncClient):
to: Event = \ to: Event = \
self.models[self.user_id, room_id, "events"][reply_to_event_id] self.models[self.user_id, room_id, "events"][reply_to_event_id]
source_body = getattr(to.source, "body", "")
content["format"] = "org.matrix.custom.html" content["format"] = "org.matrix.custom.html"
content["body"] = f"> <{to.sender_id}> {to.origin_body}" content["body"] = f"> <{to.sender_id}> {source_body}"
to_html = REPLY_FALLBACK.format( to_html = REPLY_FALLBACK.format(
room_id = room_id, room_id = room_id,
event_id = reply_to_event_id, event_id = reply_to_event_id,
user_id = to.sender_id, user_id = to.sender_id,
content = content =
to.origin_formatted_body or html.escape(to.origin_body), getattr(to.source, "formatted_body", "") or
source_body or
html.escape(to.source.source["type"] if to.source else ""),
reply_content = to_html, reply_content = to_html,
) )
@ -459,8 +463,6 @@ class MatrixClient(nio.AsyncClient):
event_type, event_type,
content = echo_body, content = echo_body,
mentions = mentions, mentions = mentions,
origin_body = content["body"],
origin_formatted_body = content.get("formatted_body") or "",
) )
await self._send_message(room_id, content, tx_id) await self._send_message(room_id, content, tx_id)
@ -697,7 +699,6 @@ class MatrixClient(nio.AsyncClient):
transaction_id, transaction_id,
event_type, event_type,
inline_content = content["body"], inline_content = content["body"],
origin_body = content["body"],
media_url = url, media_url = url,
media_title = path.name, media_title = path.name,
media_width = content["info"].get("w", 0), media_width = content["info"].get("w", 0),
@ -1437,9 +1438,6 @@ class MatrixClient(nio.AsyncClient):
target_avatar = target_avatar, target_avatar = target_avatar,
links = Event.parse_links(content), links = Event.parse_links(content),
origin_body = getattr(ev, "body", "") or "",
origin_formatted_body = getattr(ev, "formatted_body", "") or "",
fetch_profile = fetch_profile =
(must_fetch_sender or must_fetch_target) (must_fetch_sender or must_fetch_target)
if override_fetch_profile is None else if override_fetch_profile is None else

View File

@ -219,8 +219,6 @@ class Event(ModelItem):
sender_avatar: str = field() sender_avatar: str = field()
fetch_profile: bool = False fetch_profile: bool = False
origin_body: str = ""
origin_formatted_body: str = ""
content: str = "" content: str = ""
inline_content: str = "" inline_content: str = ""
reason: str = "" reason: str = ""