Use constants for NotifyProps keys. (#9901)
We have constants for (most) of the notify props keys. We should use them consistently, instead of sometimes and other times having strings scattered around the place.
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
1607d18e55
Коммит
09eae76c00
@@ -13,8 +13,8 @@ func (a *App) SendAutoResponse(channel *model.Channel, receiver *model.User) {
|
||||
return
|
||||
}
|
||||
|
||||
active := receiver.NotifyProps["auto_responder_active"] == "true"
|
||||
message := receiver.NotifyProps["auto_responder_message"]
|
||||
active := receiver.NotifyProps[model.AUTO_RESPONDER_ACTIVE_NOTIFY_PROP] == "true"
|
||||
message := receiver.NotifyProps[model.AUTO_RESPONDER_MESSAGE_NOTIFY_PROP]
|
||||
|
||||
if active && message != "" {
|
||||
autoResponderPost := &model.Post{
|
||||
@@ -33,8 +33,8 @@ func (a *App) SendAutoResponse(channel *model.Channel, receiver *model.User) {
|
||||
}
|
||||
|
||||
func (a *App) SetAutoResponderStatus(user *model.User, oldNotifyProps model.StringMap) {
|
||||
active := user.NotifyProps["auto_responder_active"] == "true"
|
||||
oldActive := oldNotifyProps["auto_responder_active"] == "true"
|
||||
active := user.NotifyProps[model.AUTO_RESPONDER_ACTIVE_NOTIFY_PROP] == "true"
|
||||
oldActive := oldNotifyProps[model.AUTO_RESPONDER_ACTIVE_NOTIFY_PROP] == "true"
|
||||
|
||||
autoResponderEnabled := !oldActive && active
|
||||
autoResponderDisabled := oldActive && !active
|
||||
@@ -52,12 +52,12 @@ func (a *App) DisableAutoResponder(userId string, asAdmin bool) *model.AppError
|
||||
return err
|
||||
}
|
||||
|
||||
active := user.NotifyProps["auto_responder_active"] == "true"
|
||||
active := user.NotifyProps[model.AUTO_RESPONDER_ACTIVE_NOTIFY_PROP] == "true"
|
||||
|
||||
if active {
|
||||
patch := &model.UserPatch{}
|
||||
patch.NotifyProps = user.NotifyProps
|
||||
patch.NotifyProps["auto_responder_active"] = "false"
|
||||
patch.NotifyProps[model.AUTO_RESPONDER_ACTIVE_NOTIFY_PROP] = "false"
|
||||
|
||||
_, err := a.PatchUser(userId, patch, asAdmin)
|
||||
if err != nil {
|
||||
|
||||
@@ -104,7 +104,7 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
|
||||
if len(post.RootId) > 0 && parentPostList != nil {
|
||||
for _, threadPost := range parentPostList.Posts {
|
||||
profile := profileMap[threadPost.UserId]
|
||||
if profile != nil && (profile.NotifyProps["comments"] == THREAD_ANY || (profile.NotifyProps["comments"] == THREAD_ROOT && threadPost.Id == parentPostList.Order[0])) {
|
||||
if profile != nil && (profile.NotifyProps[model.COMMENTS_NOTIFY_PROP] == THREAD_ANY || (profile.NotifyProps[model.COMMENTS_NOTIFY_PROP] == THREAD_ROOT && threadPost.Id == parentPostList.Order[0])) {
|
||||
if threadPost.Id == parentPostList.Order[0] {
|
||||
threadMentionedUserIds[threadPost.UserId] = THREAD_ROOT
|
||||
} else {
|
||||
@@ -565,9 +565,9 @@ func (a *App) GetMentionKeywordsInChannel(profiles map[string]*model.User, lookF
|
||||
userMention := "@" + strings.ToLower(profile.Username)
|
||||
keywords[userMention] = append(keywords[userMention], id)
|
||||
|
||||
if len(profile.NotifyProps["mention_keys"]) > 0 {
|
||||
if len(profile.NotifyProps[model.MENTION_KEYS_NOTIFY_PROP]) > 0 {
|
||||
// Add all the user's mention keys
|
||||
splitKeys := strings.Split(profile.NotifyProps["mention_keys"], ",")
|
||||
splitKeys := strings.Split(profile.NotifyProps[model.MENTION_KEYS_NOTIFY_PROP], ",")
|
||||
for _, k := range splitKeys {
|
||||
// note that these are made lower case so that we can do a case insensitive check for them
|
||||
key := strings.ToLower(k)
|
||||
@@ -576,7 +576,7 @@ func (a *App) GetMentionKeywordsInChannel(profiles map[string]*model.User, lookF
|
||||
}
|
||||
|
||||
// If turned on, add the user's case sensitive first name
|
||||
if profile.NotifyProps["first_name"] == "true" {
|
||||
if profile.NotifyProps[model.FIRST_NAME_NOTIFY_PROP] == "true" {
|
||||
keywords[profile.FirstName] = append(keywords[profile.FirstName], profile.Id)
|
||||
}
|
||||
|
||||
@@ -589,7 +589,7 @@ func (a *App) GetMentionKeywordsInChannel(profiles map[string]*model.User, lookF
|
||||
|
||||
// Add @channel and @all to keywords if user has them turned on
|
||||
if lookForSpecialMentions {
|
||||
if int64(len(profiles)) <= *a.Config().TeamSettings.MaxNotificationsPerChannel && profile.NotifyProps["channel"] == "true" && !ignoreChannelMentions {
|
||||
if int64(len(profiles)) <= *a.Config().TeamSettings.MaxNotificationsPerChannel && profile.NotifyProps[model.CHANNEL_MENTIONS_NOTIFY_PROP] == "true" && !ignoreChannelMentions {
|
||||
keywords["@channel"] = append(keywords["@channel"], profile.Id)
|
||||
keywords["@all"] = append(keywords["@all"], profile.Id)
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ func DoesStatusAllowPushNotification(userNotifyProps model.StringMap, status *mo
|
||||
return false
|
||||
}
|
||||
|
||||
pushStatus, ok := userNotifyProps["push_status"]
|
||||
pushStatus, ok := userNotifyProps[model.PUSH_STATUS_NOTIFY_PROP]
|
||||
if (pushStatus == model.STATUS_ONLINE || !ok) && (status.ActiveChannel != channelId || model.GetMillis()-status.LastActivityAt > model.STATUS_CHANNEL_TIMEOUT) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -695,7 +695,7 @@ func (a *App) GetTeamUnread(teamId, userId string) (*model.TeamUnread, *model.Ap
|
||||
for _, cu := range channelUnreads {
|
||||
teamUnread.MentionCount += cu.MentionCount
|
||||
|
||||
if cu.NotifyProps["mark_unread"] != model.CHANNEL_MARK_UNREAD_MENTION {
|
||||
if cu.NotifyProps[model.MARK_UNREAD_NOTIFY_PROP] != model.CHANNEL_MARK_UNREAD_MENTION {
|
||||
teamUnread.MsgCount += cu.MsgCount
|
||||
}
|
||||
}
|
||||
@@ -914,7 +914,7 @@ func (a *App) GetTeamsUnreadForUser(excludeTeamId string, userId string) ([]*mod
|
||||
unreads := func(cu *model.ChannelUnread, tu *model.TeamUnread) *model.TeamUnread {
|
||||
tu.MentionCount += cu.MentionCount
|
||||
|
||||
if cu.NotifyProps["mark_unread"] != model.CHANNEL_MARK_UNREAD_MENTION {
|
||||
if cu.NotifyProps[model.MARK_UNREAD_NOTIFY_PROP] != model.CHANNEL_MARK_UNREAD_MENTION {
|
||||
tu.MsgCount += cu.MsgCount
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user