Notifications: format replies properly
This commit is contained in:
parent
4cd562e02f
commit
22e7dc7e8d
|
@ -337,6 +337,7 @@ class HTMLProcessor:
|
|||
self._img_to_a,
|
||||
self._remove_extra_newlines,
|
||||
self._newlines_to_return_symbol if inline else lambda el: el,
|
||||
self._reply_to_inline if inline else lambda el: el,
|
||||
],
|
||||
"element_postprocessors": [
|
||||
self._font_color_to_span if outgoing else lambda el: el,
|
||||
|
@ -458,6 +459,16 @@ class HTMLProcessor:
|
|||
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(
|
||||
self,
|
||||
el: HtmlElement,
|
||||
|
|
|
@ -2230,9 +2230,12 @@ class MatrixClient(nio.AsyncClient):
|
|||
body = f"{sender}: {item.inline_content}"
|
||||
|
||||
NotificationRequested(
|
||||
title = room_name,
|
||||
body = body.replace(" ⏎ ", "<br>"),
|
||||
high_importance = highlight,
|
||||
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,
|
||||
) if item.sender_avatar else "",
|
||||
|
|
Loading…
Reference in New Issue
Block a user