From 9b85d1c589a353500d33ad8cd31762abfd52ee1c Mon Sep 17 00:00:00 2001 From: Michal Iskierko Date: Fri, 5 Jul 2024 16:39:37 +0200 Subject: [PATCH] fix: replace newline from message with br to display newlines correctly Fix #15291 --- bridge/status/status.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bridge/status/status.go b/bridge/status/status.go index 67d0db2e1a..7decc2e208 100644 --- a/bridge/status/status.go +++ b/bridge/status/status.go @@ -223,6 +223,10 @@ func (b *Bstatus) propagateMessage(msg *common.Message) { } } +func (b *Bstatus) nl2br(input string) string { + return strings.Replace(input, "\n", "
", -1) +} + // Converts a bridge message into a Status message func (b *Bstatus) toStatusMsg(msg config.Message) *common.Message { message := common.NewMessage() @@ -283,6 +287,8 @@ func (b *Bstatus) Send(msg config.Message) (string, error) { return "", fmt.Errorf("bridge %s not connected, dropping message %#v to bridge", b.Account, msg) } + msg.Text = b.nl2br(msg.Text) + b.Log.Debugf("=> Sending message %#v", msg) statusMessageToSend := b.toStatusMsg(msg)