mirror of
https://github.com/pushbits/server.git
synced 2025-05-28 08:16:35 +02:00
multiple smaller fixes and improvements
This commit is contained in:
parent
a1558f6f63
commit
728c84676c
4 changed files with 9 additions and 21 deletions
|
@ -259,27 +259,15 @@ func (d *Dispatcher) respondToMessage(a *model.Application, body, formattedBody
|
|||
|
||||
// Extracts body and formatted body from a matrix message event
|
||||
func bodiesFromMessage(message *event.Event) (body, formattedBody string, err error) {
|
||||
if val, ok := message.Content.Raw["body"]; ok {
|
||||
body, ok := val.(string)
|
||||
|
||||
if !ok {
|
||||
return "", "", pberrors.ErrorMessageNotFound
|
||||
}
|
||||
|
||||
formattedBody = body
|
||||
|
||||
} else {
|
||||
msgContent := message.Content.AsMessage()
|
||||
if msgContent == nil {
|
||||
return "", "", pberrors.ErrorMessageNotFound
|
||||
}
|
||||
|
||||
if val, ok := message.Content.Raw["formatted_body"]; ok {
|
||||
body, ok := val.(string)
|
||||
if !ok {
|
||||
return "", "", pberrors.ErrorMessageNotFound
|
||||
}
|
||||
|
||||
formattedBody = body
|
||||
formattedBody = msgContent.FormattedBody
|
||||
if formattedBody == "" {
|
||||
formattedBody = msgContent.Body
|
||||
}
|
||||
|
||||
return body, formattedBody, nil
|
||||
return msgContent.Body, formattedBody, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue