add modify conversation api

pull/455/head
Gordon 3 years ago committed by Xinwei Xiong(cubxxw-openim)
parent 9e593085c1
commit 9b6446c95e

@ -49,7 +49,7 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo
} }
haveUserID, _ := imdb.GetExistConversationUserIDList(req.Conversation.ConversationID) haveUserID, _ := imdb.GetExistConversationUserIDList(req.Conversation.ConversationID)
switch req.FieldType { switch req.FieldType {
case constant.RecvMsgOpt: case constant.FieldRecvMsgOpt:
for _, v := range req.UserIDList { for _, v := range req.UserIDList {
if err = db.DB.SetSingleConversationRecvMsgOpt(v, req.Conversation.ConversationID, req.Conversation.RecvMsgOpt); err != nil { 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()) 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}) 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}) 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}) 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}) 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}) 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}) 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}) err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"attached_info": conversation.AttachedInfo})
} }
if err != nil { if err != nil {
@ -86,7 +86,7 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo
} }
} }
// notification // 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 //sync peer user conversation if conversation is singleChatType
if err := syncPeerUserConversation(req.Conversation, req.OperationID); err != nil { if err := syncPeerUserConversation(req.Conversation, req.OperationID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "syncPeerUserConversation", err.Error()) log.NewError(req.OperationID, utils.GetSelfFuncName(), "syncPeerUserConversation", err.Error())

@ -265,7 +265,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
} }
conversationReq.Conversation = &conversation conversationReq.Conversation = &conversation
conversationReq.OperationID = pb.OperationID conversationReq.OperationID = pb.OperationID
conversationReq.FieldType = constant.GroupAtType conversationReq.FieldType = constant.FieldGroupAtType
tagAll := utils.IsContain(constant.AtAllString, pb.MsgData.AtUserIDList) tagAll := utils.IsContain(constant.AtAllString, pb.MsgData.AtUserIDList)
if tagAll { if tagAll {
atUserID = utils.DifferenceString([]string{constant.AtAllString}, pb.MsgData.AtUserIDList) atUserID = utils.DifferenceString([]string{constant.AtAllString}, pb.MsgData.AtUserIDList)

@ -201,13 +201,13 @@ var ContentType2PushContent = map[int64]string{
} }
const ( const (
RecvMsgOpt = 1 FieldRecvMsgOpt = 1
IsPinned = 2 FieldIsPinned = 2
AttachedInfo = 3 FieldAttachedInfo = 3
IsPrivateChat = 4 FieldIsPrivateChat = 4
GroupAtType = 5 FieldGroupAtType = 5
IsNotInGroup = 6 FieldIsNotInGroup = 6
Ex = 7 FieldEx = 7
) )
const ( const (

Loading…
Cancel
Save