aboutsummaryrefslogtreecommitdiffstats
path: root/routers/utils/utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/utils/utils.go')
-rw-r--r--routers/utils/utils.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/routers/utils/utils.go b/routers/utils/utils.go
index 6ead7d60e2..7c90fd7048 100644
--- a/routers/utils/utils.go
+++ b/routers/utils/utils.go
@@ -15,3 +15,22 @@ func RemoveUsernameParameterSuffix(name string) string {
}
return name
}
+
+// IsValidSlackChannel validates a channel name conforms to what slack expects.
+// It makes sure a channel name cannot be empty and invalid ( only an # )
+func IsValidSlackChannel(channelName string) bool {
+ switch len(strings.TrimSpace(channelName)) {
+ case 0:
+ return false
+ case 1:
+ // Keep default behaviour where a channel name is still
+ // valid without an #
+ // But if it contains only an #, it should be regarded as
+ // invalid
+ if channelName[0] == '#' {
+ return false
+ }
+ }
+
+ return true
+}