From f26170540f840899fd7608e7043b9057e1a40cdc Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Wed, 18 May 2022 11:49:24 +0800 Subject: [PATCH] options add value --- internal/api/manage/management_chat.go | 3 +-- pkg/utils/map.go | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/api/manage/management_chat.go b/internal/api/manage/management_chat.go index 3ac48cf10..19770887f 100644 --- a/internal/api/manage/management_chat.go +++ b/internal/api/manage/management_chat.go @@ -48,9 +48,8 @@ func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq { newContent = params.Content["revokeMsgClientID"].(string) default: } - var options map[string]bool + options := make(map[string]bool, 5) if params.IsOnlineOnly { - options = make(map[string]bool, 5) utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false) utils.SetSwitchFromOptions(options, constant.IsHistory, false) utils.SetSwitchFromOptions(options, constant.IsPersistent, false) diff --git a/pkg/utils/map.go b/pkg/utils/map.go index fc24cc87d..66ca27471 100644 --- a/pkg/utils/map.go +++ b/pkg/utils/map.go @@ -116,6 +116,9 @@ func JsonStringToMap(str string) (tempMap map[string]int32) { return tempMap } func GetSwitchFromOptions(Options map[string]bool, key string) (result bool) { + if Options == nil { + return true + } if flag, ok := Options[key]; !ok || flag { return true }