treewide: separate user and channel namespaces

Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
Sumner Evans
2024-09-24 14:40:41 -06:00
parent 65da56b2a6
commit c6e96682b6
15 changed files with 132 additions and 60 deletions
+13 -2
View File
@@ -13,8 +13,19 @@ func MakeUserID(userID int64) networkid.UserID {
return networkid.UserID(strconv.FormatInt(userID, 10))
}
func ParseUserID(userID networkid.UserID) (int64, error) {
return strconv.ParseInt(string(userID), 10, 64)
func MakeChannelUserID(channelID int64) networkid.UserID {
return networkid.UserID("channel-" + strconv.FormatInt(channelID, 10))
}
func ParseUserID(userID networkid.UserID) (PeerType, int64, error) {
peerType := PeerTypeUser
rawUserID := string(userID)
if strings.HasPrefix(string(userID), "channel-") {
peerType = PeerTypeChannel
rawUserID = strings.TrimPrefix(rawUserID, "channel-")
}
id, err := strconv.ParseInt(rawUserID, 10, 64)
return peerType, id, err
}
func ParseUserLoginID(userID networkid.UserLoginID) (int64, error) {