diff --git a/cmd/open_im_timer_task/main.go b/cmd/open_im_timer_task/main.go index d5cf8150c..56fd6a4c0 100644 --- a/cmd/open_im_timer_task/main.go +++ b/cmd/open_im_timer_task/main.go @@ -42,17 +42,17 @@ func main() { for { uidList, err := im_mysql_model.SelectAllUID() if err != nil { - log.NewError("999999", err.Error()) + //log.NewError("999999", err.Error()) } else { for _, v := range uidList { minSeq, err := commonDB.DB.GetMinSeqFromMongo(v) if err != nil { - log.NewError("999999", "get user minSeq err", err.Error(), v) + //log.NewError("999999", "get user minSeq err", err.Error(), v) continue } else { err := commonDB.DB.SetUserMinSeq(v, minSeq) if err != nil { - log.NewError("999999", "set user minSeq err", err.Error(), v) + //log.NewError("999999", "set user minSeq err", err.Error(), v) } } time.Sleep(time.Duration(100) * time.Millisecond) diff --git a/internal/api/chat/get_max_min_seq.go b/internal/api/chat/get_max_min_seq.go index 7103cae4a..984497c18 100644 --- a/internal/api/chat/get_max_min_seq.go +++ b/internal/api/chat/get_max_min_seq.go @@ -42,7 +42,8 @@ func UserGetSeq(c *gin.Context) { msgClient := pbMsg.NewChatClient(grpcConn) reply, err := msgClient.GetMaxAndMinSeq(context.Background(), &pbData) if err != nil { - log.ErrorByKv("rpc call failed to getNewSeq", pbData.OperationID, "err", err, "pbData", pbData.String()) + log.NewError(params.OperationID, "UserGetSeq rpc failed, ", params, err.Error()) + c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "UserGetSeq rpc failed, " + err.Error()}) return } diff --git a/internal/api/chat/pull_msg.go b/internal/api/chat/pull_msg.go index 46b568284..c0fa578e9 100644 --- a/internal/api/chat/pull_msg.go +++ b/internal/api/chat/pull_msg.go @@ -43,7 +43,8 @@ func UserPullMsg(c *gin.Context) { msgClient := pbChat.NewChatClient(grpcConn) reply, err := msgClient.PullMessage(context.Background(), &pbData) if err != nil { - log.ErrorByKv("PullMessage error", pbData.OperationID, "err", err.Error()) + log.NewError(params.OperationID, "UserPullMsg rpc failed, ", params, err.Error()) + c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "UserPullMsg rpc failed, " + err.Error()}) return } log.InfoByKv("rpc call success to pullMsgRep", pbData.OperationID, "ReplyArgs", reply.String(), "maxSeq", reply.GetMaxSeq(), diff --git a/internal/api/chat/send_msg.go b/internal/api/chat/send_msg.go index 6d7294109..e48582eb1 100644 --- a/internal/api/chat/send_msg.go +++ b/internal/api/chat/send_msg.go @@ -27,7 +27,7 @@ type paramsUserSendMsg struct { RecvID string `json:"recvID" binding:"required"` ForceList []string `json:"forceList"` Content string `json:"content" binding:"required"` - Options map[string]interface{} `json:"options" ` + Options map[string]int32 `json:"options" ` ClientMsgID string `json:"clientMsgID" binding:"required"` OffLineInfo map[string]interface{} `json:"offlineInfo" ` Ex map[string]interface{} `json:"ext"` @@ -49,7 +49,7 @@ func newUserSendMsgReq(token string, params *paramsUserSendMsg) *pbChat.UserSend RecvID: params.Data.RecvID, ForceList: params.Data.ForceList, Content: params.Data.Content, - Options: utils.MapToJsonString(params.Data.Options), + Options: utils.MapIntToJsonString(params.Data.Options), ClientMsgID: params.Data.ClientMsgID, OffLineInfo: utils.MapToJsonString(params.Data.OffLineInfo), Ex: utils.MapToJsonString(params.Data.Ex), @@ -77,7 +77,12 @@ func UserSendMsg(c *gin.Context) { log.Info("", "", "api UserSendMsg call, api call rpc...") - reply, _ := client.UserSendMsg(context.Background(), pbData) + reply, err := client.UserSendMsg(context.Background(), pbData) + if err != nil { + log.NewError(params.OperationID, "UserSendMsg rpc failed, ", params, err.Error()) + c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "UserSendMsg rpc failed, " + err.Error()}) + return + } log.Info("", "", "api UserSendMsg call end..., [data: %s] [reply: %s]", pbData.String(), reply.String()) c.JSON(http.StatusOK, gin.H{ diff --git a/internal/api/conversation/conversation.go b/internal/api/conversation/conversation.go index 718af6f9f..4e4316b05 100644 --- a/internal/api/conversation/conversation.go +++ b/internal/api/conversation/conversation.go @@ -15,7 +15,7 @@ import ( type paramsSetReceiveMessageOpt struct { OperationID string `json:"operationID" binding:"required"` - Option int32 `json:"option" binding:"required"` + Option *int32 `json:"option" binding:"required"` ConversationIdList []string `json:"conversationIdList" binding:"required"` } @@ -31,7 +31,7 @@ type SetReceiveMessageOptResp struct { } type paramGetReceiveMessageOpt struct { - ConversationIdList []string `json:"ConversationIdList" binding:"required"` + ConversationIdList []string `json:"conversationIdList" binding:"required"` OperationID string `json:"operationID" binding:"required"` } @@ -159,7 +159,7 @@ func SetReceiveMessageOpt(c *gin.Context) { req := &user.SetReceiveMessageOptReq{ UId: claims.UID, - Opt: params.Option, + Opt: *params.Option, ConversationId: params.ConversationIdList, OperationID: params.OperationID, } diff --git a/internal/msg_transfer/logic/history_msg_handler.go b/internal/msg_transfer/logic/history_msg_handler.go index e3b5efb05..4b25bd9bc 100644 --- a/internal/msg_transfer/logic/history_msg_handler.go +++ b/internal/msg_transfer/logic/history_msg_handler.go @@ -54,11 +54,11 @@ func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string) pbSaveData.OperationID = pbData.OperationID pbSaveData.RecvID = pbData.RecvID pbSaveData.PlatformID = pbData.PlatformID - Options := utils.JsonStringToMap(pbData.Options) + options := utils.JsonStringToMap(pbData.Options) //Control whether to store offline messages (mongo) - isHistory := utils.GetSwitchFromOptions(Options, "history") + isHistory := utils.GetSwitchFromOptions(options, "history") //Control whether to store history messages (mysql) - isPersist := utils.GetSwitchFromOptions(Options, "persistent") + isPersist := utils.GetSwitchFromOptions(options, "persistent") switch pbData.SessionType { case constant.SingleChatType: log.NewDebug(pbSaveData.OperationID, "msg_transfer chat type = SingleChatType", isHistory, isPersist) diff --git a/internal/msg_transfer/logic/persistent_msg_handler.go b/internal/msg_transfer/logic/persistent_msg_handler.go index 88039041c..2a13bb4a2 100644 --- a/internal/msg_transfer/logic/persistent_msg_handler.go +++ b/internal/msg_transfer/logic/persistent_msg_handler.go @@ -40,9 +40,9 @@ func (pc *PersistentConsumerHandler) handleChatWs2Mysql(msg []byte, msgKey strin log.ErrorByKv("msg_transfer Unmarshal chat err", "", "chat", string(msg), "err", err.Error()) return } - Options := utils.JsonStringToMap(pbData.Options) + options := utils.JsonStringToMap(pbData.Options) //Control whether to store history messages (mysql) - isPersist := utils.GetSwitchFromOptions(Options, "persistent") + isPersist := utils.GetSwitchFromOptions(options, "persistent") //Only process receiver data if isPersist { if msgKey == pbData.RecvID && pbData.SessionType == constant.SingleChatType { diff --git a/internal/push/jpush/push.go b/internal/push/jpush/push.go index 2fe39c27f..1258a80a7 100644 --- a/internal/push/jpush/push.go +++ b/internal/push/jpush/push.go @@ -20,15 +20,17 @@ func JGAccountListPush(accounts []string, content, detailContent, platform strin var au requestBody.Audience au.SetAlias(accounts) var no requestBody.Notification - no.SetAlert(content) - no.SetAndroidIntent() + no.SetAlert(content, platform) var me requestBody.Message me.SetMsgContent(detailContent) + var o requestBody.Options + o.SetApnsProduction(false) var po requestBody.PushObj po.SetPlatform(&pf) po.SetAudience(&au) po.SetNotification(&no) po.SetMessage(&me) + po.SetOptions(&o) con, err := json.Marshal(po) if err != nil { diff --git a/internal/push/jpush/requestBody/notification.go b/internal/push/jpush/requestBody/notification.go index 838621606..3f2876612 100644 --- a/internal/push/jpush/requestBody/notification.go +++ b/internal/push/jpush/requestBody/notification.go @@ -1,6 +1,9 @@ package requestBody -import "Open_IM/pkg/common/config" +import ( + "Open_IM/pkg/common/config" + "Open_IM/pkg/common/constant" +) type Notification struct { Alert string `json:"alert,omitempty"` @@ -15,11 +18,23 @@ type Android struct { } `json:"intent,omitempty"` } type Ios struct { + Alert string `json:"alert,omitempty"` + Sound string `json:"sound,omitempty"` + Badge string `json:"badge,omitempty"` } -func (n *Notification) SetAlert(alert string) { +func (n *Notification) SetAlert(alert, platform string) { n.Alert = alert - n.Android.Alert = alert + switch platform { + case constant.AndroidPlatformStr: + n.Android.Alert = alert + n.SetAndroidIntent() + case constant.IOSPlatformStr: + n.IOS.Alert = alert + n.IOS.Sound = "default" + n.IOS.Badge = "+1" + default: + } } func (n *Notification) SetAndroidIntent() { n.Android.Intent.URL = config.Config.Push.Jpns.PushIntent diff --git a/internal/push/jpush/requestBody/options.go b/internal/push/jpush/requestBody/options.go new file mode 100644 index 000000000..f82ebd035 --- /dev/null +++ b/internal/push/jpush/requestBody/options.go @@ -0,0 +1,9 @@ +package requestBody + +type Options struct { + ApnsProduction bool `json:"apns_production"` +} + +func (o *Options) SetApnsProduction(c bool) { + o.ApnsProduction = c +} diff --git a/internal/push/jpush/requestBody/pushObj.go b/internal/push/jpush/requestBody/pushObj.go index 24c912b26..974161407 100644 --- a/internal/push/jpush/requestBody/pushObj.go +++ b/internal/push/jpush/requestBody/pushObj.go @@ -5,6 +5,7 @@ type PushObj struct { Audience interface{} `json:"audience"` Notification interface{} `json:"notification,omitempty"` Message interface{} `json:"message,omitempty"` + Options interface{} `json:"options,omitempty"` } func (p *PushObj) SetPlatform(pf *Platform) { @@ -22,3 +23,6 @@ func (p *PushObj) SetNotification(no *Notification) { func (p *PushObj) SetMessage(m *Message) { p.Message = m } +func (p *PushObj) SetOptions(o *Options) { + p.Options = o +} diff --git a/internal/push/logic/push_handler.go b/internal/push/logic/push_handler.go index 22382a5b9..5058ce26d 100644 --- a/internal/push/logic/push_handler.go +++ b/internal/push/logic/push_handler.go @@ -12,6 +12,7 @@ import ( "Open_IM/pkg/common/log" pbChat "Open_IM/pkg/proto/chat" pbRelay "Open_IM/pkg/proto/relay" + "Open_IM/pkg/utils" "github.com/Shopify/sarama" "github.com/golang/protobuf/proto" ) @@ -53,7 +54,7 @@ func (ms *PushConsumerHandler) handleMs2PsChat(msg []byte) { sendPbData.PlatformID = pbData.PlatformID sendPbData.RecvSeq = pbData.RecvSeq //Call push module to send message to the user - MsgToUser(&sendPbData, pbData.OfflineInfo, pbData.Options) + MsgToUser(&sendPbData, pbData.OfflineInfo, utils.JsonStringToMap(pbData.Options)) } func (PushConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil } func (PushConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil } diff --git a/internal/push/logic/push_rpc_server.go b/internal/push/logic/push_rpc_server.go index ca0e93880..570f5c28b 100644 --- a/internal/push/logic/push_rpc_server.go +++ b/internal/push/logic/push_rpc_server.go @@ -65,7 +65,7 @@ func (r *RPCServer) PushMsg(_ context.Context, pbData *pbPush.PushMsgReq) (*pbPu sendPbData.PlatformID = pbData.PlatformID sendPbData.RecvSeq = pbData.RecvSeq //Call push module to send message to the user - MsgToUser(&sendPbData, pbData.OfflineInfo, pbData.Options) + MsgToUser(&sendPbData, pbData.OfflineInfo, utils.JsonStringToMap(pbData.Options)) return &pbPush.PushMsgResp{ ResultCode: 0, }, nil diff --git a/internal/push/logic/push_to_client.go b/internal/push/logic/push_to_client.go index 390ba42c5..b7c8c94af 100644 --- a/internal/push/logic/push_to_client.go +++ b/internal/push/logic/push_to_client.go @@ -34,12 +34,10 @@ type AtContent struct { IsAtSelf bool `json:"isAtSelf"` } -func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo, Options string) { +func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo string, Options map[string]int32) { var wsResult []*pbRelay.SingleMsgToUser - MOptions := utils.JsonStringToMap(Options) //Control whether to push message to sender's other terminal - //isSenderSync := utils.GetSwitchFromOptions(MOptions, "senderSync") - isOfflinePush := utils.GetSwitchFromOptions(MOptions, "offlinePush") - log.InfoByKv("Get chat from msg_transfer And push chat", sendPbData.OperationID, "PushData", sendPbData) + isOfflinePush := utils.GetSwitchFromOptions(Options, "offlinePush") + log.InfoByKv("Get chat from msg_transfer And push chat", sendPbData.OperationID, "PushData", sendPbData, Options, isOfflinePush) grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName) //Online push message log.InfoByKv("test", sendPbData.OperationID, "len grpc", len(grpcCons), "data", sendPbData) @@ -100,9 +98,9 @@ func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo, Options string) { } pushResult, err := push.JGAccountListPush(UIDList, content, jsonCustomContent, constant.PlatformIDToName(t)) if err != nil { - log.NewError(sendPbData.OperationID, "offline push error", sendPbData.String(), err.Error(), t) + log.NewError(sendPbData.OperationID, "offline push error", sendPbData.String(), err.Error(), constant.PlatformIDToName(t)) } else { - log.NewDebug(sendPbData.OperationID, "offline push return result is ", string(pushResult), sendPbData, t) + log.NewDebug(sendPbData.OperationID, "offline push return result is ", string(pushResult), sendPbData, constant.PlatformIDToName(t)) } } diff --git a/internal/rpc/chat/send_msg.go b/internal/rpc/chat/send_msg.go index b0e8f663a..cc9e56177 100644 --- a/internal/rpc/chat/send_msg.go +++ b/internal/rpc/chat/send_msg.go @@ -71,8 +71,8 @@ func (rpc *rpcChat) UserSendMsg(_ context.Context, pb *pbChat.UserSendMsgReq) (* } else { pbData.SendTime = pb.SendTime } - Options := utils.JsonStringToMap(pbData.Options) - isHistory := utils.GetSwitchFromOptions(Options, "history") + options := utils.JsonStringToMap(pbData.Options) + isHistory := utils.GetSwitchFromOptions(options, "history") mReq := MsgCallBackReq{ SendID: pb.SendID, RecvID: pb.RecvID, @@ -190,6 +190,20 @@ func (rpc *rpcChat) UserSendMsg(_ context.Context, pb *pbChat.UserSendMsgReq) (* } +} + +type WSToMsgSvrChatMsg struct { + SendID string `protobuf:"bytes,1,opt,name=SendID" json:"SendID,omitempty"` + RecvID string `protobuf:"bytes,2,opt,name=RecvID" json:"RecvID,omitempty"` + Content string `protobuf:"bytes,3,opt,name=Content" json:"Content,omitempty"` + MsgFrom int32 `protobuf:"varint,5,opt,name=MsgFrom" json:"MsgFrom,omitempty"` + ContentType int32 `protobuf:"varint,8,opt,name=ContentType" json:"ContentType,omitempty"` + SessionType int32 `protobuf:"varint,9,opt,name=SessionType" json:"SessionType,omitempty"` + OperationID string `protobuf:"bytes,10,opt,name=OperationID" json:"OperationID,omitempty"` +} + +func Notification(m *WSToMsgSvrChatMsg, onlineUserOnly bool, offlineInfo interface{}) { + } func (rpc *rpcChat) sendMsgToKafka(m *pbChat.WSToMsgSvrChatMsg, key string) error { pid, offset, err := rpc.producer.SendMessage(m, key) @@ -224,10 +238,12 @@ func modifyMessageByUserMessageReceiveOpt(userID, sourceID string, sessionType i case constant.NotReceiveMessage: return false case constant.ReceiveNotNotifyMessage: - m := utils.JsonStringToMap(msg.OfflineInfo) - utils.SetSwitchFromOptions(m, "offlinePush", 0) - s := utils.MapToJsonString(m) - msg.OfflineInfo = s + options := utils.JsonStringToMap(msg.Options) + if options == nil { + options = make(map[string]int32, 2) + } + utils.SetSwitchFromOptions(options, "offlinePush", 0) + msg.Options = utils.MapIntToJsonString(options) return true } diff --git a/pkg/common/db/mongoModel.go b/pkg/common/db/mongoModel.go index 93f64ff5f..4137616ea 100644 --- a/pkg/common/db/mongoModel.go +++ b/pkg/common/db/mongoModel.go @@ -198,14 +198,14 @@ func (d *DataBases) SaveUserChat(uid string, sendTime int64, m *pbMsg.MsgSvrToPu return errors.New("session == nil") } defer session.Close() - log.NewInfo("", "get mgoSession cost time", getCurrentTimestampByMill()-newTime) + log.NewDebug("", "get mgoSession cost time", getCurrentTimestampByMill()-newTime) c := session.DB(config.Config.Mongo.DBDatabase).C(cChat) seqUid = getSeqUid(uid, m.RecvSeq) n, err := c.Find(bson.M{"uid": seqUid}).Count() if err != nil { return err } - log.NewInfo("", "find mgo uid cost time", getCurrentTimestampByMill()-newTime) + log.NewDebug("", "find mgo uid cost time", getCurrentTimestampByMill()-newTime) sMsg := MsgInfo{} sMsg.SendTime = sendTime if sMsg.Msg, err = proto.Marshal(m); err != nil { @@ -225,7 +225,7 @@ func (d *DataBases) SaveUserChat(uid string, sendTime int64, m *pbMsg.MsgSvrToPu return err } } - log.NewInfo("", "insert mgo data cost time", getCurrentTimestampByMill()-newTime) + log.NewDebug("", "insert mgo data cost time", getCurrentTimestampByMill()-newTime) return nil } diff --git a/pkg/proto/chat/chat.pb.go b/pkg/proto/chat/chat.pb.go index b48d2cee1..dfe51b472 100644 --- a/pkg/proto/chat/chat.pb.go +++ b/pkg/proto/chat/chat.pb.go @@ -50,7 +50,7 @@ func (m *WSToMsgSvrChatMsg) Reset() { *m = WSToMsgSvrChatMsg{} } func (m *WSToMsgSvrChatMsg) String() string { return proto.CompactTextString(m) } func (*WSToMsgSvrChatMsg) ProtoMessage() {} func (*WSToMsgSvrChatMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_chat_feb94a5514034c46, []int{0} + return fileDescriptor_chat_163a8d226aa6edb5, []int{0} } func (m *WSToMsgSvrChatMsg) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_WSToMsgSvrChatMsg.Unmarshal(m, b) @@ -215,7 +215,7 @@ func (m *MsgSvrToPushSvrChatMsg) Reset() { *m = MsgSvrToPushSvrChatMsg{} func (m *MsgSvrToPushSvrChatMsg) String() string { return proto.CompactTextString(m) } func (*MsgSvrToPushSvrChatMsg) ProtoMessage() {} func (*MsgSvrToPushSvrChatMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_chat_feb94a5514034c46, []int{1} + return fileDescriptor_chat_163a8d226aa6edb5, []int{1} } func (m *MsgSvrToPushSvrChatMsg) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MsgSvrToPushSvrChatMsg.Unmarshal(m, b) @@ -361,7 +361,7 @@ func (m *PullMessageReq) Reset() { *m = PullMessageReq{} } func (m *PullMessageReq) String() string { return proto.CompactTextString(m) } func (*PullMessageReq) ProtoMessage() {} func (*PullMessageReq) Descriptor() ([]byte, []int) { - return fileDescriptor_chat_feb94a5514034c46, []int{2} + return fileDescriptor_chat_163a8d226aa6edb5, []int{2} } func (m *PullMessageReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_PullMessageReq.Unmarshal(m, b) @@ -425,7 +425,7 @@ func (m *PullMessageResp) Reset() { *m = PullMessageResp{} } func (m *PullMessageResp) String() string { return proto.CompactTextString(m) } func (*PullMessageResp) ProtoMessage() {} func (*PullMessageResp) Descriptor() ([]byte, []int) { - return fileDescriptor_chat_feb94a5514034c46, []int{3} + return fileDescriptor_chat_163a8d226aa6edb5, []int{3} } func (m *PullMessageResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_PullMessageResp.Unmarshal(m, b) @@ -500,7 +500,7 @@ func (m *PullMessageBySeqListReq) Reset() { *m = PullMessageBySeqListReq func (m *PullMessageBySeqListReq) String() string { return proto.CompactTextString(m) } func (*PullMessageBySeqListReq) ProtoMessage() {} func (*PullMessageBySeqListReq) Descriptor() ([]byte, []int) { - return fileDescriptor_chat_feb94a5514034c46, []int{4} + return fileDescriptor_chat_163a8d226aa6edb5, []int{4} } func (m *PullMessageBySeqListReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_PullMessageBySeqListReq.Unmarshal(m, b) @@ -553,7 +553,7 @@ func (m *GetMaxAndMinSeqReq) Reset() { *m = GetMaxAndMinSeqReq{} } func (m *GetMaxAndMinSeqReq) String() string { return proto.CompactTextString(m) } func (*GetMaxAndMinSeqReq) ProtoMessage() {} func (*GetMaxAndMinSeqReq) Descriptor() ([]byte, []int) { - return fileDescriptor_chat_feb94a5514034c46, []int{5} + return fileDescriptor_chat_163a8d226aa6edb5, []int{5} } func (m *GetMaxAndMinSeqReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetMaxAndMinSeqReq.Unmarshal(m, b) @@ -601,7 +601,7 @@ func (m *GetMaxAndMinSeqResp) Reset() { *m = GetMaxAndMinSeqResp{} } func (m *GetMaxAndMinSeqResp) String() string { return proto.CompactTextString(m) } func (*GetMaxAndMinSeqResp) ProtoMessage() {} func (*GetMaxAndMinSeqResp) Descriptor() ([]byte, []int) { - return fileDescriptor_chat_feb94a5514034c46, []int{6} + return fileDescriptor_chat_163a8d226aa6edb5, []int{6} } func (m *GetMaxAndMinSeqResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetMaxAndMinSeqResp.Unmarshal(m, b) @@ -663,7 +663,7 @@ func (m *GatherFormat) Reset() { *m = GatherFormat{} } func (m *GatherFormat) String() string { return proto.CompactTextString(m) } func (*GatherFormat) ProtoMessage() {} func (*GatherFormat) Descriptor() ([]byte, []int) { - return fileDescriptor_chat_feb94a5514034c46, []int{7} + return fileDescriptor_chat_163a8d226aa6edb5, []int{7} } func (m *GatherFormat) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GatherFormat.Unmarshal(m, b) @@ -731,7 +731,7 @@ func (m *MsgFormat) Reset() { *m = MsgFormat{} } func (m *MsgFormat) String() string { return proto.CompactTextString(m) } func (*MsgFormat) ProtoMessage() {} func (*MsgFormat) Descriptor() ([]byte, []int) { - return fileDescriptor_chat_feb94a5514034c46, []int{8} + return fileDescriptor_chat_163a8d226aa6edb5, []int{8} } func (m *MsgFormat) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MsgFormat.Unmarshal(m, b) @@ -863,7 +863,7 @@ func (m *UserSendMsgReq) Reset() { *m = UserSendMsgReq{} } func (m *UserSendMsgReq) String() string { return proto.CompactTextString(m) } func (*UserSendMsgReq) ProtoMessage() {} func (*UserSendMsgReq) Descriptor() ([]byte, []int) { - return fileDescriptor_chat_feb94a5514034c46, []int{9} + return fileDescriptor_chat_163a8d226aa6edb5, []int{9} } func (m *UserSendMsgReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UserSendMsgReq.Unmarshal(m, b) @@ -1025,7 +1025,7 @@ func (m *UserSendMsgResp) Reset() { *m = UserSendMsgResp{} } func (m *UserSendMsgResp) String() string { return proto.CompactTextString(m) } func (*UserSendMsgResp) ProtoMessage() {} func (*UserSendMsgResp) Descriptor() ([]byte, []int) { - return fileDescriptor_chat_feb94a5514034c46, []int{10} + return fileDescriptor_chat_163a8d226aa6edb5, []int{10} } func (m *UserSendMsgResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UserSendMsgResp.Unmarshal(m, b) @@ -1272,9 +1272,9 @@ var _Chat_serviceDesc = grpc.ServiceDesc{ Metadata: "chat/chat.proto", } -func init() { proto.RegisterFile("chat/chat.proto", fileDescriptor_chat_feb94a5514034c46) } +func init() { proto.RegisterFile("chat/chat.proto", fileDescriptor_chat_163a8d226aa6edb5) } -var fileDescriptor_chat_feb94a5514034c46 = []byte{ +var fileDescriptor_chat_163a8d226aa6edb5 = []byte{ // 981 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xdd, 0x6a, 0xe3, 0x46, 0x14, 0xc6, 0x92, 0x2d, 0xdb, 0xc7, 0xbf, 0x99, 0x86, 0xec, 0x90, 0x96, 0xd6, 0x88, 0x6d, 0x31, diff --git a/pkg/proto/push/push.pb.go b/pkg/proto/push/push.pb.go index 2fdbd2f53..b53d2b8a1 100644 --- a/pkg/proto/push/push.pb.go +++ b/pkg/proto/push/push.pb.go @@ -49,7 +49,7 @@ func (m *PushMsgReq) Reset() { *m = PushMsgReq{} } func (m *PushMsgReq) String() string { return proto.CompactTextString(m) } func (*PushMsgReq) ProtoMessage() {} func (*PushMsgReq) Descriptor() ([]byte, []int) { - return fileDescriptor_push_4f08d2ff54ba8af2, []int{0} + return fileDescriptor_push_e44270f7d93180b9, []int{0} } func (m *PushMsgReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_PushMsgReq.Unmarshal(m, b) @@ -192,7 +192,7 @@ func (m *PushMsgResp) Reset() { *m = PushMsgResp{} } func (m *PushMsgResp) String() string { return proto.CompactTextString(m) } func (*PushMsgResp) ProtoMessage() {} func (*PushMsgResp) Descriptor() ([]byte, []int) { - return fileDescriptor_push_4f08d2ff54ba8af2, []int{1} + return fileDescriptor_push_e44270f7d93180b9, []int{1} } func (m *PushMsgResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_PushMsgResp.Unmarshal(m, b) @@ -296,9 +296,9 @@ var _PushMsgService_serviceDesc = grpc.ServiceDesc{ Metadata: "push/push.proto", } -func init() { proto.RegisterFile("push/push.proto", fileDescriptor_push_4f08d2ff54ba8af2) } +func init() { proto.RegisterFile("push/push.proto", fileDescriptor_push_e44270f7d93180b9) } -var fileDescriptor_push_4f08d2ff54ba8af2 = []byte{ +var fileDescriptor_push_e44270f7d93180b9 = []byte{ // 378 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0x5d, 0xeb, 0xda, 0x30, 0x14, 0xc6, 0xe9, 0xb4, 0xbe, 0x1c, 0xe7, 0xcb, 0xc2, 0x18, 0xc1, 0x8b, 0x51, 0x64, 0x0c, 0x6f, diff --git a/pkg/utils/map.go b/pkg/utils/map.go index 48acadc60..4b8f9fa8d 100644 --- a/pkg/utils/map.go +++ b/pkg/utils/map.go @@ -111,16 +111,16 @@ func MapIntToJsonString(param map[string]int32) string { dataString := string(dataType) return dataString } -func JsonStringToMap(str string) (tempMap map[string]interface{}) { +func JsonStringToMap(str string) (tempMap map[string]int32) { _ = json.Unmarshal([]byte(str), &tempMap) return tempMap } -func GetSwitchFromOptions(Options map[string]interface{}, key string) (result bool) { - if flag, ok := Options[key]; !ok || flag.(int) == 1 { +func GetSwitchFromOptions(Options map[string]int32, key string) (result bool) { + if flag, ok := Options[key]; !ok || flag == 1 { return true } return false } -func SetSwitchFromOptions(Options map[string]interface{}, key string, value interface{}) { +func SetSwitchFromOptions(Options map[string]int32, key string, value int32) { Options[key] = value }