aboutsummaryrefslogblamecommitdiff
path: root/appservice/names.go
blob: 9ed00f87de31660884c2b4766f30510acd8c5e2a (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                                             
                                                                                  


                                                  

                                                                                  
 




                                                
 
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
}