Make OOB compatible with RawMessages

This commit is contained in:
Bohdan Horbeshko 2023-01-16 08:02:41 -05:00
parent b3b53b6145
commit 559d6443e5

View file

@ -764,34 +764,34 @@ func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message) {
text = c.messageToText(message, false) text = c.messageToText(message, false)
// OTR support (I do not know why would you need it, seriously) // OTR support (I do not know why would you need it, seriously)
if !(strings.HasPrefix(text, "?OTR") || c.Session.RawMessages) { if !(strings.HasPrefix(text, "?OTR") || (c.Session.RawMessages && !c.Session.OOBMode)) {
file, preview := c.contentToFile(content) file, preview := c.contentToFile(content)
// download file and preview (if present) // download file and preview (if present)
file = c.ensureDownloadFile(file) file = c.ensureDownloadFile(file)
preview = c.ensureDownloadFile(preview) preview = c.ensureDownloadFile(preview)
var prefix strings.Builder
previewName, _ := c.formatFile(preview, true) previewName, _ := c.formatFile(preview, true)
fileName, link := c.formatFile(file, false) fileName, link := c.formatFile(file, false)
prefix.WriteString(c.messageToPrefix(message, previewName, fileName))
oob = link oob = link
if text != "" { if c.Session.OOBMode && oob != "" {
// \n if it is groupchat and message is not empty text = oob
if chatId < 0 { } else if !c.Session.RawMessages {
prefix.WriteString("\n") var prefix strings.Builder
} else if chatId > 0 { prefix.WriteString(c.messageToPrefix(message, previewName, fileName))
prefix.WriteString(" | ") if text != "" {
// \n if it is groupchat and message is not empty
if chatId < 0 {
prefix.WriteString("\n")
} else if chatId > 0 {
prefix.WriteString(" | ")
}
prefix.WriteString(text)
} }
text = prefix.String()
prefix.WriteString(text)
} }
text = prefix.String()
}
if c.Session.OOBMode && oob != "" {
text = oob
} }
} }