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:
parent
b09b3b990b
commit
66f9a17111
|
@ -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,
|
||||||
)
|
)
|
||||||
|
@ -457,10 +461,8 @@ class MatrixClient(nio.AsyncClient):
|
||||||
room_id,
|
room_id,
|
||||||
tx_id,
|
tx_id,
|
||||||
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
|
||||||
|
|
|
@ -219,13 +219,11 @@ class Event(ModelItem):
|
||||||
sender_avatar: str = field()
|
sender_avatar: str = field()
|
||||||
fetch_profile: bool = False
|
fetch_profile: bool = False
|
||||||
|
|
||||||
origin_body: str = ""
|
content: str = ""
|
||||||
origin_formatted_body: str = ""
|
inline_content: str = ""
|
||||||
content: str = ""
|
reason: str = ""
|
||||||
inline_content: str = ""
|
links: List[str] = field(default_factory=list)
|
||||||
reason: str = ""
|
mentions: List[Tuple[str, str]] = field(default_factory=list)
|
||||||
links: List[str] = field(default_factory=list)
|
|
||||||
mentions: List[Tuple[str, str]] = field(default_factory=list)
|
|
||||||
|
|
||||||
type_specifier: TypeSpecifier = TypeSpecifier.Unset
|
type_specifier: TypeSpecifier = TypeSpecifier.Unset
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user