Escape @room in reply fallback to avoid unintentional pings

Closes https://github.com/SchildiChat/SchildiChat-android/issues/178

Change-Id: I8a545dd80d29802d1b35b0315fca89125c997f15
This commit is contained in:
SpiritCroc 2023-03-09 10:42:07 +01:00
parent e875b0d731
commit 80edce3d6c
2 changed files with 8 additions and 2 deletions

View File

@ -34,6 +34,7 @@ Here you can find some extra features and changes compared to Element Android (w
- Render image reactions
- Send freeform reactions
- Render media captions ([MSC2530](https://github.com/matrix-org/matrix-spec-proposals/pull/2530))
- Escape @room in the reply fallback to avoid unintentional room pings when replying
- Branding (name, app icon, links)
- Show a toast instead of a snackbar after copying text, in order to not block the input area right after copying

View File

@ -637,7 +637,7 @@ internal class LocalEchoEventFactory @Inject constructor(
permalink,
userLink,
userId,
bodyFormatted,
bodyFormatted.escapeRoomPings(),
finalReplyTextFormatted
)
//
@ -726,7 +726,7 @@ internal class LocalEchoEventFactory @Inject constructor(
append(originalSenderId)
append(">")
val lines = body.text.split("\n")
val lines = body.text.escapeRoomPings().split("\n")
lines.forEachIndexed { index, s ->
if (index == 0) {
append(" $s")
@ -739,6 +739,11 @@ internal class LocalEchoEventFactory @Inject constructor(
}
}
private fun String.escapeRoomPings(): String {
// Escape @room, so replying as moderator will not ping the whole room
return replace("@room", "@\u2060room")
}
private fun bodyForReply(timelineEvent: TimelineEvent, isRedactedEvent: Boolean = false): TextContent {
val content = when (timelineEvent.root.getClearType()) {
in EventType.POLL_END.values -> {