From 9b6446c95ee3a235dad3f880e373728631a34469 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Sun, 24 Apr 2022 17:27:26 +0800 Subject: [PATCH] add modify conversation api --- internal/rpc/conversation/conversaion.go | 16 ++++++++-------- internal/rpc/msg/send_msg.go | 2 +- pkg/common/constant/constant.go | 14 +++++++------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/rpc/conversation/conversaion.go b/internal/rpc/conversation/conversaion.go index 409c1e488..aec03fd26 100644 --- a/internal/rpc/conversation/conversaion.go +++ b/internal/rpc/conversation/conversaion.go @@ -49,7 +49,7 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo } haveUserID, _ := imdb.GetExistConversationUserIDList(req.Conversation.ConversationID) switch req.FieldType { - case constant.RecvMsgOpt: + case constant.FieldRecvMsgOpt: for _, v := range req.UserIDList { if err = db.DB.SetSingleConversationRecvMsgOpt(v, req.Conversation.ConversationID, req.Conversation.RecvMsgOpt); err != nil { log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error()) @@ -58,17 +58,17 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo } } err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"recv_msg_opt": conversation.RecvMsgOpt}) - case constant.GroupAtType: + case constant.FieldGroupAtType: err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"group_at_type": conversation.GroupAtType}) - case constant.IsNotInGroup: + case constant.FieldIsNotInGroup: err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"is_not_in_group": conversation.IsNotInGroup}) - case constant.IsPinned: + case constant.FieldIsPinned: err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"is_pinned": conversation.IsPinned}) - case constant.IsPrivateChat: + case constant.FieldIsPrivateChat: err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"is_private_chat": conversation.IsPrivateChat}) - case constant.Ex: + case constant.FieldEx: err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"ex": conversation.Ex}) - case constant.AttachedInfo: + case constant.FieldAttachedInfo: err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"attached_info": conversation.AttachedInfo}) } if err != nil { @@ -86,7 +86,7 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo } } // notification - if req.Conversation.ConversationType == constant.SingleChatType && req.FieldType == constant.IsPrivateChat { + if req.Conversation.ConversationType == constant.SingleChatType && req.FieldType == constant.FieldIsPrivateChat { //sync peer user conversation if conversation is singleChatType if err := syncPeerUserConversation(req.Conversation, req.OperationID); err != nil { log.NewError(req.OperationID, utils.GetSelfFuncName(), "syncPeerUserConversation", err.Error()) diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index 16fba65dc..21dae7207 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -265,7 +265,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S } conversationReq.Conversation = &conversation conversationReq.OperationID = pb.OperationID - conversationReq.FieldType = constant.GroupAtType + conversationReq.FieldType = constant.FieldGroupAtType tagAll := utils.IsContain(constant.AtAllString, pb.MsgData.AtUserIDList) if tagAll { atUserID = utils.DifferenceString([]string{constant.AtAllString}, pb.MsgData.AtUserIDList) diff --git a/pkg/common/constant/constant.go b/pkg/common/constant/constant.go index 000c3e909..e36b2b1f3 100644 --- a/pkg/common/constant/constant.go +++ b/pkg/common/constant/constant.go @@ -201,13 +201,13 @@ var ContentType2PushContent = map[int64]string{ } const ( - RecvMsgOpt = 1 - IsPinned = 2 - AttachedInfo = 3 - IsPrivateChat = 4 - GroupAtType = 5 - IsNotInGroup = 6 - Ex = 7 + FieldRecvMsgOpt = 1 + FieldIsPinned = 2 + FieldAttachedInfo = 3 + FieldIsPrivateChat = 4 + FieldGroupAtType = 5 + FieldIsNotInGroup = 6 + FieldEx = 7 ) const (