easybridge/appservice/names.go

24 lines
545 B
Go
Raw Normal View History

2020-02-16 21:07:41 +00:00
package appservice
import (
"fmt"
"strings"
. "git.deuxfleurs.fr/Deuxfleurs/easybridge/connector"
)
func roomAlias(protocol string, id RoomID) string {
2020-02-18 16:17:04 +00:00
return fmt.Sprintf("_ezbr__%s__%s", safeStringForId(string(id)), protocol)
2020-02-16 21:07:41 +00:00
}
func userMxId(protocol string, id UserID) string {
2020-02-18 16:17:04 +00:00
return fmt.Sprintf("_ezbr__%s__%s", safeStringForId(string(id)), protocol)
}
2020-02-16 21:07:41 +00:00
2020-02-18 16:17:04 +00:00
func safeStringForId(in string) string {
id2 := strings.ReplaceAll(in, "#", "")
id2 = strings.ReplaceAll(id2, "@", "__")
id2 = strings.ReplaceAll(id2, ":", "_")
return id2
2020-02-16 21:07:41 +00:00
}