diff options
author | Tulir Asokan <tulir@maunium.net> | 2019-03-26 00:37:35 +0200 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2019-03-26 00:37:35 +0200 |
commit | 8aa134b8b23cf945f5a18e21e5fa4855e188d3c0 (patch) | |
tree | 008f0f5e48688e752e1cb6279c4fa43bcfcc05cd /ui/messages/parser | |
parent | ae36b9cddd1332fbf3ec3160ef4ad269619e445b (diff) |
Start moving to mauview
Diffstat (limited to 'ui/messages/parser')
-rw-r--r-- | ui/messages/parser/parser.go | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/ui/messages/parser/parser.go b/ui/messages/parser/parser.go index 94ab5b6..b36fde0 100644 --- a/ui/messages/parser/parser.go +++ b/ui/messages/parser/parser.go @@ -102,14 +102,24 @@ func ParseMessage(matrix ifc.MatrixContainer, room *rooms.Room, evt *mautrix.Eve } if len(evt.Content.GetReplyTo()) > 0 { evt.Content.RemoveReplyFallback() - replyToEvt, _ := matrix.Client().GetEvent(room.ID, evt.Content.GetReplyTo()) - replyToEvt.Content.RemoveReplyFallback() - if len(replyToEvt.Content.FormattedBody) == 0 { - replyToEvt.Content.FormattedBody = html.EscapeString(replyToEvt.Content.Body) + roomID := evt.Content.RelatesTo.InReplyTo.RoomID + if len(roomID) == 0 { + roomID = room.ID + } + replyToEvt, _ := matrix.Client().GetEvent(roomID, evt.Content.GetReplyTo()) + if replyToEvt != nil { + replyToEvt.Content.RemoveReplyFallback() + if len(replyToEvt.Content.FormattedBody) == 0 { + replyToEvt.Content.FormattedBody = html.EscapeString(replyToEvt.Content.Body) + } + evt.Content.FormattedBody = fmt.Sprintf( + "In reply to <a href='https://matrix.to/#/%[1]s'>%[1]s</a><blockquote>%[2]s</blockquote><br/>%[3]s", + replyToEvt.Sender, replyToEvt.Content.FormattedBody, evt.Content.FormattedBody) + } else { + evt.Content.FormattedBody = fmt.Sprintf( + "In reply to unknown event https://matrix.to/#/%[1]s/%[2]s<br/>%[3]s", + roomID, evt.Content.GetReplyTo(), evt.Content.FormattedBody) } - evt.Content.FormattedBody = fmt.Sprintf( - "In reply to <a href='https://matrix.to/#/%[1]s'>%[1]s</a><blockquote>%[2]s</blockquote><br/>%[3]s", - replyToEvt.Sender, replyToEvt.Content.FormattedBody, evt.Content.FormattedBody) } ts := unixToTime(evt.Timestamp) switch evt.Content.MsgType { |