summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2017-07-26 08:51:25 +0100
committerGitHub <noreply@github.com>2017-07-26 08:51:25 +0100
commit4132a02319a9cf07cbd13c989de9b891d89f8fb3 (patch)
treec1ef4d4c102176d83ae70664cf557ad70a3704aa /model
parent489151d2d2ab821b51637a67c53b41246dfcd9b4 (diff)
downloadchat-4132a02319a9cf07cbd13c989de9b891d89f8fb3.tar.gz
chat-4132a02319a9cf07cbd13c989de9b891d89f8fb3.tar.bz2
chat-4132a02319a9cf07cbd13c989de9b891d89f8fb3.zip
PLT-7183: User/Channel NotifyProps Bulk Import. (#7019)
Diffstat (limited to 'model')
-rw-r--r--model/user.go43
-rw-r--r--model/utils.go16
2 files changed, 49 insertions, 10 deletions
diff --git a/model/user.go b/model/user.go
index 8e5c8fcc1..ab4b21e23 100644
--- a/model/user.go
+++ b/model/user.go
@@ -16,14 +16,23 @@ import (
)
const (
- ME = "me"
- USER_NOTIFY_ALL = "all"
- USER_NOTIFY_MENTION = "mention"
- USER_NOTIFY_NONE = "none"
- DESKTOP_NOTIFY_PROP = "desktop"
- MARK_UNREAD_NOTIFY_PROP = "mark_unread"
- PUSH_NOTIFY_PROP = "push"
- EMAIL_NOTIFY_PROP = "email"
+ ME = "me"
+ USER_NOTIFY_ALL = "all"
+ USER_NOTIFY_MENTION = "mention"
+ USER_NOTIFY_NONE = "none"
+ DESKTOP_NOTIFY_PROP = "desktop"
+ DESKTOP_SOUND_NOTIFY_PROP = "desktop_sound"
+ DESKTOP_DURATION_NOTIFY_PROP = "desktop_duration"
+ MARK_UNREAD_NOTIFY_PROP = "mark_unread"
+ PUSH_NOTIFY_PROP = "push"
+ PUSH_STATUS_NOTIFY_PROP = "push_status"
+ EMAIL_NOTIFY_PROP = "email"
+ CHANNEL_MENTIONS_NOTIFY_PROP = "channel"
+ COMMENTS_NOTIFY_PROP = "comments"
+ MENTION_KEYS_NOTIFY_PROP = "mention_keys"
+ COMMENTS_NOTIFY_NEVER = "never"
+ COMMENTS_NOTIFY_ROOT = "root"
+ COMMENTS_NOTIFY_ANY = "any"
DEFAULT_LOCALE = "en"
USER_AUTH_SERVICE_EMAIL = "email"
@@ -604,3 +613,21 @@ func CleanUsername(s string) string {
return s
}
+
+func IsValidUserNotifyLevel(notifyLevel string) bool {
+ return notifyLevel == CHANNEL_NOTIFY_ALL ||
+ notifyLevel == CHANNEL_NOTIFY_MENTION ||
+ notifyLevel == CHANNEL_NOTIFY_NONE
+}
+
+func IsValidPushStatusNotifyLevel(notifyLevel string) bool {
+ return notifyLevel == STATUS_ONLINE ||
+ notifyLevel == STATUS_AWAY ||
+ notifyLevel == STATUS_OFFLINE
+}
+
+func IsValidCommentsNotifyLevel(notifyLevel string) bool {
+ return notifyLevel == COMMENTS_NOTIFY_ANY ||
+ notifyLevel == COMMENTS_NOTIFY_ROOT ||
+ notifyLevel == COMMENTS_NOTIFY_NEVER
+}
diff --git a/model/utils.go b/model/utils.go
index 7f612b572..090644ec6 100644
--- a/model/utils.go
+++ b/model/utils.go
@@ -11,14 +11,14 @@ import (
"fmt"
"io"
"io/ioutil"
+ "net"
"net/mail"
"net/url"
"regexp"
+ "strconv"
"strings"
"time"
- "net"
-
goi18n "github.com/nicksnyder/go-i18n/i18n"
"github.com/pborman/uuid"
)
@@ -480,3 +480,15 @@ func IsValidWebsocketUrl(rawUrl string) bool {
return true
}
+
+func IsValidTrueOrFalseString(value string) bool {
+ return value == "true" || value == "false"
+}
+
+func IsValidNumberString(value string) bool {
+ if _, err := strconv.Atoi(value); err != nil {
+ return false
+ }
+
+ return true
+}