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,18 +764,22 @@ 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 c.Session.OOBMode && oob != "" {
text = oob
} else if !c.Session.RawMessages {
var prefix strings.Builder
prefix.WriteString(c.messageToPrefix(message, previewName, fileName))
if text != "" { if text != "" {
// \n if it is groupchat and message is not empty // \n if it is groupchat and message is not empty
if chatId < 0 { if chatId < 0 {
@ -786,12 +790,8 @@ func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message) {
prefix.WriteString(text) prefix.WriteString(text)
} }
text = prefix.String() text = prefix.String()
} }
if c.Session.OOBMode && oob != "" {
text = oob
} }
} }