aboutsummaryrefslogtreecommitdiff
path: root/appservice/names.go
blob: 9ed00f87de31660884c2b4766f30510acd8c5e2a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package appservice

import (
	"fmt"
	"strings"

	. "git.deuxfleurs.fr/Deuxfleurs/easybridge/connector"
)

func roomAlias(protocol string, id RoomID) string {
	return fmt.Sprintf("_ezbr__%s__%s", safeStringForId(string(id)), protocol)
}

func userMxId(protocol string, id UserID) string {
	return fmt.Sprintf("_ezbr__%s__%s", safeStringForId(string(id)), protocol)
}

func safeStringForId(in string) string {
	id2 := strings.ReplaceAll(in, "#", "")
	id2 = strings.ReplaceAll(id2, "@", "__")
	id2 = strings.ReplaceAll(id2, ":", "_")
	return id2
}