From 748a416961923932e9b2969beb2730ee8c240ea7 Mon Sep 17 00:00:00 2001 From: enahum Date: Thu, 23 Feb 2017 11:08:48 -0300 Subject: =?UTF-8?q?PLT-3193=20Add=20channel=20notification=20preferences?= =?UTF-8?q?=20for=20push=20and=20email=20noti=E2=80=A6=20(#5500)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * PLT-3193 Add channel notification preferences for push and email notifications * unit tests, model validation and localization * Feedback review * Adding back allowFromCache check * Setting push and email to use default settings * Move props as constants * address feedback --- app/channel.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'app/channel.go') diff --git a/app/channel.go b/app/channel.go index db007dd3b..fb4198c37 100644 --- a/app/channel.go +++ b/app/channel.go @@ -226,18 +226,27 @@ func UpdateChannelMemberNotifyProps(data map[string]string, channelId string, us } // update whichever notify properties have been provided, but don't change the others - if markUnread, exists := data["mark_unread"]; exists { - member.NotifyProps["mark_unread"] = markUnread + if markUnread, exists := data[model.MARK_UNREAD_NOTIFY_PROP]; exists { + member.NotifyProps[model.MARK_UNREAD_NOTIFY_PROP] = markUnread } - if desktop, exists := data["desktop"]; exists { - member.NotifyProps["desktop"] = desktop + if desktop, exists := data[model.DESKTOP_NOTIFY_PROP]; exists { + member.NotifyProps[model.DESKTOP_NOTIFY_PROP] = desktop + } + + if email, exists := data[model.EMAIL_NOTIFY_PROP]; exists { + member.NotifyProps[model.EMAIL_NOTIFY_PROP] = email + } + + if push, exists := data[model.PUSH_NOTIFY_PROP]; exists { + member.NotifyProps[model.PUSH_NOTIFY_PROP] = push } if result := <-Srv.Store.Channel().UpdateMember(member); result.Err != nil { return nil, result.Err } else { InvalidateCacheForUser(userId) + InvalidateCacheForChannelMembersNotifyProps(channelId) return member, nil } } -- cgit v1.2.3-1-g7c22