Notifications: format replies properly
This commit is contained in:
parent
4cd562e02f
commit
22e7dc7e8d
|
@ -337,6 +337,7 @@ class HTMLProcessor:
|
||||||
self._img_to_a,
|
self._img_to_a,
|
||||||
self._remove_extra_newlines,
|
self._remove_extra_newlines,
|
||||||
self._newlines_to_return_symbol if inline else lambda el: el,
|
self._newlines_to_return_symbol if inline else lambda el: el,
|
||||||
|
self._reply_to_inline if inline else lambda el: el,
|
||||||
],
|
],
|
||||||
"element_postprocessors": [
|
"element_postprocessors": [
|
||||||
self._font_color_to_span if outgoing else lambda el: el,
|
self._font_color_to_span if outgoing else lambda el: el,
|
||||||
|
@ -458,6 +459,16 @@ class HTMLProcessor:
|
||||||
return el
|
return el
|
||||||
|
|
||||||
|
|
||||||
|
def _reply_to_inline(self, el: HtmlElement) -> HtmlElement:
|
||||||
|
"""Turn <mx-reply> into a plaintext inline form."""
|
||||||
|
|
||||||
|
if el.tag != "mx-reply":
|
||||||
|
return el
|
||||||
|
|
||||||
|
el.tail = f" ⏎⏎ {el.tail or ''}"
|
||||||
|
return el
|
||||||
|
|
||||||
|
|
||||||
def _mentions_to_matrix_to_links(
|
def _mentions_to_matrix_to_links(
|
||||||
self,
|
self,
|
||||||
el: HtmlElement,
|
el: HtmlElement,
|
||||||
|
|
|
@ -2230,10 +2230,13 @@ class MatrixClient(nio.AsyncClient):
|
||||||
body = f"{sender}: {item.inline_content}"
|
body = f"{sender}: {item.inline_content}"
|
||||||
|
|
||||||
NotificationRequested(
|
NotificationRequested(
|
||||||
title = room_name,
|
|
||||||
body = body.replace(" ⏎ ", "<br>"),
|
|
||||||
high_importance = highlight,
|
high_importance = highlight,
|
||||||
image = await self.get_notification_avatar(
|
title = room_name,
|
||||||
|
|
||||||
|
body = body.replace(" ⏎ ", "<br>")
|
||||||
|
.replace(" ⏎⏎ ", f"<br>{'─' * 24}<br>"),
|
||||||
|
|
||||||
|
image = await self.get_notification_avatar(
|
||||||
mxc=item.sender_avatar, user_id=item.sender_id,
|
mxc=item.sender_avatar, user_id=item.sender_id,
|
||||||
) if item.sender_avatar else "",
|
) if item.sender_avatar else "",
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user