summaryrefslogtreecommitdiffstats
path: root/bridge/nctalk/nctalk.go
diff options
context:
space:
mode:
authorTilo Spannagel <development@tilosp.de>2020-08-31 01:49:43 +0200
committerGitHub <noreply@github.com>2020-08-31 01:49:43 +0200
commit712385ffd58ad01d1c257b63a7b0299134d95209 (patch)
treecacc41eec61d0bc72b28197c896682ed26db775b /bridge/nctalk/nctalk.go
parentad90cf09fe26693d1ba325cd2d578fcf0e39a90d (diff)
downloadmatterbridge-msglm-712385ffd58ad01d1c257b63a7b0299134d95209.tar.gz
matterbridge-msglm-712385ffd58ad01d1c257b63a7b0299134d95209.tar.bz2
matterbridge-msglm-712385ffd58ad01d1c257b63a7b0299134d95209.zip
Format rich object strings (nctalk) (#1222)
Signed-off-by: Tilo Spannagel <development@tilosp.de>
Diffstat (limited to 'bridge/nctalk/nctalk.go')
-rw-r--r--bridge/nctalk/nctalk.go23
1 files changed, 22 insertions, 1 deletions
diff --git a/bridge/nctalk/nctalk.go b/bridge/nctalk/nctalk.go
index 40836a4f..94bb1a08 100644
--- a/bridge/nctalk/nctalk.go
+++ b/bridge/nctalk/nctalk.go
@@ -4,6 +4,7 @@ import (
"context"
"crypto/tls"
"strconv"
+ "strings"
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
@@ -78,7 +79,7 @@ func (b *Btalk) JoinChannel(channel config.ChannelInfo) error {
continue
}
remoteMessage := config.Message{
- Text: msg.Message,
+ Text: formatRichObjectString(msg.Message, msg.MessageParameters),
Channel: newRoom.room.Token,
Username: msg.ActorDisplayName,
UserID: msg.ActorID,
@@ -123,3 +124,23 @@ func (b *Btalk) getRoom(token string) *Broom {
}
return nil
}
+
+// Spec: https://github.com/nextcloud/server/issues/1706#issue-182308785
+func formatRichObjectString(message string, parameters map[string]ocs.RichObjectString) string {
+ for id, parameter := range parameters {
+ text := parameter.Name
+
+ switch parameter.Type {
+ case ocs.ROSTypeUser, ocs.ROSTypeGroup:
+ text = "@" + text
+ case ocs.ROSTypeFile:
+ if parameter.Link != "" {
+ text = parameter.Link
+ }
+ }
+
+ message = strings.ReplaceAll(message, "{"+id+"}", text)
+ }
+
+ return message
+}