refactor common logic

This commit is contained in:
Jonhnny Weslley
2016-01-24 11:54:06 -03:00
parent 517462a7af
commit ba3b699517
3 changed files with 14 additions and 4 deletions
+9
View File
@@ -12,6 +12,7 @@ import (
"math"
"math/rand"
"regexp"
"strings"
)
var validChannelName *regexp.Regexp
@@ -38,3 +39,11 @@ func GenerateSessionID() string {
func IsChannelNameValid(channelName string) bool {
return validChannelName.Match([]byte(channelName))
}
func IsPrivateChannel(channelName string) bool {
return strings.HasPrefix(channelName, "private-")
}
func IsPresenceChannel(channelName string) bool {
return strings.HasPrefix(channelName, "presence-")
}