summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-08-23 08:47:25 -0400
committerGitHub <noreply@github.com>2016-08-23 08:47:25 -0400
commit065d01c121907bc5529d7019e53b93819daf85f3 (patch)
tree3496c273b7477d7cf0c4c42a95f4f4a1d94251dd /model
parentc93ce7af3fc89ba3f76517245d18f55b238beb11 (diff)
downloadchat-065d01c121907bc5529d7019e53b93819daf85f3.tar.gz
chat-065d01c121907bc5529d7019e53b93819daf85f3.tar.bz2
chat-065d01c121907bc5529d7019e53b93819daf85f3.zip
Add notification settings to control what statuses allow push notifications (#3829)
Diffstat (limited to 'model')
-rw-r--r--model/user.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/model/user.go b/model/user.go
index d8ad54065..3da862b6b 100644
--- a/model/user.go
+++ b/model/user.go
@@ -373,6 +373,24 @@ func (u *User) IsLDAPUser() bool {
return false
}
+func (u *User) StatusAllowsPushNotification(status *Status) bool {
+ props := u.NotifyProps
+
+ if props["push"] == "none" {
+ return false
+ }
+
+ if pushStatus, ok := props["push_status"]; pushStatus == STATUS_ONLINE || !ok {
+ return true
+ } else if pushStatus == STATUS_AWAY && (status.Status == STATUS_AWAY || status.Status == STATUS_OFFLINE) {
+ return true
+ } else if pushStatus == STATUS_OFFLINE && status.Status == STATUS_OFFLINE {
+ return true
+ }
+
+ return false
+}
+
// UserFromJson will decode the input and return a User
func UserFromJson(data io.Reader) *User {
decoder := json.NewDecoder(data)