aboutsummaryrefslogtreecommitdiff
path: root/appservice
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-02-18 17:17:04 +0100
committerAlex Auvolat <alex@adnab.me>2020-02-18 17:17:04 +0100
commitcf13f2b5af290c69bc4f1a8184b1dbe19225b36e (patch)
treea65be7436640761276c43d9db90f4a10b2ceccbc /appservice
parent78c7d1deae23d7807c130028883cf350348dc4db (diff)
downloadeasybridge-cf13f2b5af290c69bc4f1a8184b1dbe19225b36e.tar.gz
easybridge-cf13f2b5af290c69bc4f1a8184b1dbe19225b36e.zip
Handle mattermost private messages
Diffstat (limited to 'appservice')
-rw-r--r--appservice/names.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/appservice/names.go b/appservice/names.go
index 4a5d186..9ed00f8 100644
--- a/appservice/names.go
+++ b/appservice/names.go
@@ -8,14 +8,16 @@ import (
)
func roomAlias(protocol string, id RoomID) string {
- id2 := strings.ReplaceAll(string(id), "#", "")
- id2 = strings.ReplaceAll(id2, "@", "__")
-
- return fmt.Sprintf("_ezbr__%s__%s", id2, protocol)
+ return fmt.Sprintf("_ezbr__%s__%s", safeStringForId(string(id)), protocol)
}
func userMxId(protocol string, id UserID) string {
- id2 := strings.ReplaceAll(string(id), "@", "__")
+ return fmt.Sprintf("_ezbr__%s__%s", safeStringForId(string(id)), protocol)
+}
- return fmt.Sprintf("_ezbr__%s__%s", id2, protocol)
+func safeStringForId(in string) string {
+ id2 := strings.ReplaceAll(in, "#", "")
+ id2 = strings.ReplaceAll(id2, "@", "__")
+ id2 = strings.ReplaceAll(id2, ":", "_")
+ return id2
}