forked from MirrorHub/mautrix-whatsapp
Pre-render markdown for undecryptable message notice
This commit is contained in:
parent
b918b4f261
commit
43922cf09e
1 changed files with 8 additions and 3 deletions
11
portal.go
11
portal.go
|
@ -308,8 +308,14 @@ func (portal *Portal) convertMessage(intent *appservice.IntentAPI, source *User,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const UndecryptableMessage = "Decrypting message from WhatsApp failed, waiting for sender to re-send... " +
|
const UndecryptableMessageNotice = "Decrypting message from WhatsApp failed, waiting for sender to re-send... " +
|
||||||
"([learn more](https://faq.whatsapp.com/general/security-and-privacy/seeing-waiting-for-this-message-this-may-take-a-while))"
|
"([learn more](https://faq.whatsapp.com/general/security-and-privacy/seeing-waiting-for-this-message-this-may-take-a-while))"
|
||||||
|
var undecryptableMessageContent event.MessageEventContent
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
undecryptableMessageContent = format.RenderMarkdown(UndecryptableMessageNotice, true, false)
|
||||||
|
undecryptableMessageContent.MsgType = event.MsgNotice
|
||||||
|
}
|
||||||
|
|
||||||
func (portal *Portal) handleUndecryptableMessage(source *User, evt *events.UndecryptableMessage) {
|
func (portal *Portal) handleUndecryptableMessage(source *User, evt *events.UndecryptableMessage) {
|
||||||
if len(portal.MXID) == 0 {
|
if len(portal.MXID) == 0 {
|
||||||
|
@ -323,8 +329,7 @@ func (portal *Portal) handleUndecryptableMessage(source *User, evt *events.Undec
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
intent := portal.getMessageIntent(source, &evt.Info)
|
intent := portal.getMessageIntent(source, &evt.Info)
|
||||||
content := format.RenderMarkdown(UndecryptableMessage, true, false)
|
content := undecryptableMessageContent
|
||||||
content.MsgType = event.MsgNotice
|
|
||||||
resp, err := portal.sendMessage(intent, event.EventMessage, &content, evt.Info.Timestamp.UnixMilli())
|
resp, err := portal.sendMessage(intent, event.EventMessage, &content, evt.Info.Timestamp.UnixMilli())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
portal.log.Errorln("Failed to send decryption error of %s to Matrix: %v", evt.Info.ID, err)
|
portal.log.Errorln("Failed to send decryption error of %s to Matrix: %v", evt.Info.ID, err)
|
||||||
|
|
Loading…
Reference in a new issue