mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
rtc add
This commit is contained in:
parent
fa21ae6161
commit
b0aa168c9a
@ -59,13 +59,13 @@ func main() {
|
||||
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner) //1
|
||||
groupRouterGroup.POST("/get_recv_group_applicationList", group.GetRecvGroupApplicationList) //1
|
||||
groupRouterGroup.POST("/get_user_req_group_applicationList", group.GetUserReqGroupApplicationList)
|
||||
groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1
|
||||
groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1
|
||||
groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use
|
||||
groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1
|
||||
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1
|
||||
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1
|
||||
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList) //1
|
||||
groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1
|
||||
groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1
|
||||
groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use
|
||||
groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1
|
||||
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1
|
||||
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1
|
||||
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList) //1
|
||||
}
|
||||
//certificate
|
||||
authRouterGroup := r.Group("/auth")
|
||||
@ -97,12 +97,13 @@ func main() {
|
||||
}
|
||||
//Conversation
|
||||
conversationGroup := r.Group("/conversation")
|
||||
{ //1
|
||||
{ //1
|
||||
conversationGroup.POST("/get_all_conversations", conversation.GetAllConversations)
|
||||
conversationGroup.POST("/get_conversation", conversation.GetConversation)
|
||||
conversationGroup.POST("/get_conversations", conversation.GetConversations)
|
||||
conversationGroup.POST("/set_conversation", conversation.SetConversation)
|
||||
conversationGroup.POST("/batch_set_conversation", conversation.BatchSetConversations)
|
||||
conversationGroup.POST("/set_recv_msg_opt", conversation.SetRecvMsgOpt)
|
||||
}
|
||||
apiThird.MinioInit()
|
||||
log.NewPrivateLog("api")
|
||||
|
@ -15,8 +15,8 @@ import (
|
||||
|
||||
func SetConversation(c *gin.Context) {
|
||||
var (
|
||||
req api.SetConversationReq
|
||||
resp api.SetConversationResp
|
||||
req api.SetConversationReq
|
||||
resp api.SetConversationResp
|
||||
reqPb pbUser.SetConversationReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
@ -47,8 +47,8 @@ func SetConversation(c *gin.Context) {
|
||||
|
||||
func BatchSetConversations(c *gin.Context) {
|
||||
var (
|
||||
req api.BatchSetConversationsReq
|
||||
resp api.BatchSetConversationsResp
|
||||
req api.BatchSetConversationsReq
|
||||
resp api.BatchSetConversationsResp
|
||||
reqPb pbUser.BatchSetConversationsReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
@ -79,8 +79,8 @@ func BatchSetConversations(c *gin.Context) {
|
||||
|
||||
func GetAllConversations(c *gin.Context) {
|
||||
var (
|
||||
req api.GetAllConversationsReq
|
||||
resp api.GetAllConversationsResp
|
||||
req api.GetAllConversationsReq
|
||||
resp api.GetAllConversationsResp
|
||||
reqPb pbUser.GetAllConversationsReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
@ -111,8 +111,8 @@ func GetAllConversations(c *gin.Context) {
|
||||
|
||||
func GetConversation(c *gin.Context) {
|
||||
var (
|
||||
req api.GetConversationReq
|
||||
resp api.GetConversationResp
|
||||
req api.GetConversationReq
|
||||
resp api.GetConversationResp
|
||||
reqPb pbUser.GetConversationReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
@ -141,11 +141,10 @@ func GetConversation(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
|
||||
func GetConversations(c *gin.Context) {
|
||||
var (
|
||||
req api.GetConversationsReq
|
||||
resp api.GetConversationsResp
|
||||
req api.GetConversationsReq
|
||||
resp api.GetConversationsResp
|
||||
reqPb pbUser.GetConversationsReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
@ -174,33 +173,31 @@ func GetConversations(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func GetAllConversationMessageOpt(c *gin.Context) {
|
||||
func SetRecvMsgOpt(c *gin.Context) {
|
||||
var (
|
||||
_ api.GetAllConversationMessageOptReq
|
||||
resp api.GetAllConversationMessageOptResp
|
||||
)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetReceiveMessageOpt(c *gin.Context) {
|
||||
var (
|
||||
_ api.GetReceiveMessageOptReq
|
||||
resp api.GetReceiveMessageOptResp
|
||||
)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func SetReceiveMessageOpt(c *gin.Context) {
|
||||
var (
|
||||
_ api.SetReceiveMessageOptReq
|
||||
resp api.SetReceiveMessageOptResp
|
||||
req api.SetRecvMsgOptReq
|
||||
resp api.SetRecvMsgOptResp
|
||||
reqPb pbUser.SetRecvMsgOptReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.SetRecvMsgOpt(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
15
internal/rpc/msg/del_msg.go
Normal file
15
internal/rpc/msg/del_msg.go
Normal file
@ -0,0 +1,15 @@
|
||||
package msg
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/log"
|
||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
)
|
||||
|
||||
func (rpc *rpcChat) DelMsgList(_ context.Context, req *commonPb.DelMsgListReq) (*commonPb.DelMsgListResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &commonPb.DelMsgListResp{}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
return resp, nil
|
||||
}
|
@ -94,7 +94,6 @@ func (s *userServer) GetUserInfo(ctx context.Context, req *pbUser.GetUserInfoReq
|
||||
return &pbUser.GetUserInfoResp{CommonResp: &pbUser.CommonResp{}, UserInfoList: userInfoList}, nil
|
||||
}
|
||||
|
||||
|
||||
func (s *userServer) BatchSetConversations(ctx context.Context, req *pbUser.BatchSetConversationsReq) (*pbUser.BatchSetConversationsResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.BatchSetConversationsResp{}
|
||||
@ -139,20 +138,20 @@ func (s *userServer) GetAllConversations(ctx context.Context, req *pbUser.GetAll
|
||||
}
|
||||
|
||||
func (s *userServer) GetConversation(ctx context.Context, req *pbUser.GetConversationReq) (*pbUser.GetConversationResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.GetConversationResp{Conversation: &pbUser.Conversation{}}
|
||||
conversation, err := imdb.GetConversation(req.OwnerUserID, req.ConversationID)
|
||||
if err != nil{
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversation error", err.Error())
|
||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||
return resp, nil
|
||||
}
|
||||
if err := utils.CopyStructFields(resp.Conversation, &conversation); err != nil {
|
||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields error", conversation, err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||
resp.CommonResp = &pbUser.CommonResp{}
|
||||
return resp, nil
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.GetConversationResp{Conversation: &pbUser.Conversation{}}
|
||||
conversation, err := imdb.GetConversation(req.OwnerUserID, req.ConversationID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversation error", err.Error())
|
||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||
return resp, nil
|
||||
}
|
||||
if err := utils.CopyStructFields(resp.Conversation, &conversation); err != nil {
|
||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields error", conversation, err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||
resp.CommonResp = &pbUser.CommonResp{}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *userServer) GetConversations(ctx context.Context, req *pbUser.GetConversationsReq) (*pbUser.GetConversationsResp, error) {
|
||||
@ -196,56 +195,29 @@ func (s *userServer) SetConversation(ctx context.Context, req *pbUser.SetConvers
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
//func (s *userServer) SetReceiveMessageOpt(ctx context.Context, req *pbUser.SetReceiveMessageOptReq) (*pbUser.SetReceiveMessageOptResp, error) {
|
||||
// log.NewInfo(req.OperationID, "SetReceiveMessageOpt args ", req.String())
|
||||
// m := make(map[string]int, len(req.ConversationIDList))
|
||||
// for _, v := range req.ConversationIDList {
|
||||
// m[v] = int(req.Opt)
|
||||
// }
|
||||
// err := db.DB.SetMultiConversationMsgOpt(req.FromUserID, m)
|
||||
// if err != nil {
|
||||
// log.NewError(req.OperationID, "SetMultiConversationMsgOpt failed ", err.Error(), req)
|
||||
// return &pbUser.SetReceiveMessageOptResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
// }
|
||||
// resp := pbUser.SetReceiveMessageOptResp{CommonResp: &pbUser.CommonResp{}}
|
||||
//
|
||||
// for _, v := range req.ConversationIDList {
|
||||
// resp.ConversationOptResultList = append(resp.ConversationOptResultList, &pbUser.OptResult{ConversationID: v, Result: req.Opt})
|
||||
// }
|
||||
// chat.SetReceiveMessageOptNotification(req.OperationID, req.OpUserID, req.FromUserID)
|
||||
// log.NewInfo(req.OperationID, "SetReceiveMessageOpt rpc return ", resp.String())
|
||||
// return &resp, nil
|
||||
//}
|
||||
//
|
||||
//func (s *userServer) GetReceiveMessageOpt(ctx context.Context, req *pbUser.GetReceiveMessageOptReq) (*pbUser.GetReceiveMessageOptResp, error) {
|
||||
// log.NewInfo(req.OperationID, "GetReceiveMessageOpt args ", req.String())
|
||||
// m, err := db.DB.GetMultiConversationMsgOpt(req.FromUserID, req.ConversationIDList)
|
||||
// if err != nil {
|
||||
// log.NewError(req.OperationID, "GetMultiConversationMsgOpt failed ", err.Error(), req.FromUserID, req.ConversationIDList)
|
||||
// return &pbUser.GetReceiveMessageOptResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
// }
|
||||
// resp := pbUser.GetReceiveMessageOptResp{CommonResp: &pbUser.CommonResp{}}
|
||||
// for k, v := range m {
|
||||
// resp.ConversationOptResultList = append(resp.ConversationOptResultList, &pbUser.OptResult{ConversationID: k, Result: int32(v)})
|
||||
// }
|
||||
// log.NewInfo(req.OperationID, "GetReceiveMessageOpt rpc return ", resp.String())
|
||||
// return &resp, nil
|
||||
//}
|
||||
//
|
||||
//func (s *userServer) GetAllConversationMsgOpt(ctx context.Context, req *pbUser.GetAllConversationMsgOptReq) (*pbUser.GetAllConversationMsgOptResp, error) {
|
||||
// log.NewInfo(req.OperationID, "GetAllConversationMsgOpt args ", req.String())
|
||||
// m, err := db.DB.GetAllConversationMsgOpt(req.FromUserID)
|
||||
// if err != nil {
|
||||
// log.NewError(req.OperationID, "GetAllConversationMsgOpt failed ", err.Error(), req.FromUserID)
|
||||
// return &pbUser.GetAllConversationMsgOptResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
// }
|
||||
// resp := pbUser.GetAllConversationMsgOptResp{CommonResp: &pbUser.CommonResp{}}
|
||||
// for k, v := range m {
|
||||
// resp.ConversationOptResultList = append(resp.ConversationOptResultList, &pbUser.OptResult{ConversationID: k, Result: int32(v)})
|
||||
// }
|
||||
// log.NewInfo(req.OperationID, "GetAllConversationMsgOpt rpc return ", resp.String())
|
||||
// return &resp, nil
|
||||
//}
|
||||
func (s *userServer) SetRecvMsgOpt(ctx context.Context, req *pbUser.SetRecvMsgOptReq) (*pbUser.SetRecvMsgOptResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.SetRecvMsgOptResp{}
|
||||
var conversation db.Conversation
|
||||
if err := utils.CopyStructFields(&conversation, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", *req, err.Error())
|
||||
}
|
||||
if err := db.DB.SetSingleConversationRecvMsgOpt(req.OwnerUserID, req.ConversationID, req.RecvMsgOpt); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error())
|
||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||
return resp, nil
|
||||
}
|
||||
err := imdb.SetRecvMsgOpt(conversation)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
|
||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||
return resp, nil
|
||||
}
|
||||
chat.SetConversationNotification(req.OperationID, req.OwnerUserID)
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||
resp.CommonResp = &pbUser.CommonResp{}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *userServer) DeleteUsers(_ context.Context, req *pbUser.DeleteUsersReq) (*pbUser.DeleteUsersResp, error) {
|
||||
log.NewInfo(req.OperationID, "DeleteUsers args ", req.String())
|
||||
|
@ -38,10 +38,10 @@ type Conversation struct {
|
||||
ConversationType int32 `json:"conversationType"`
|
||||
UserID string `json:"userID"`
|
||||
GroupID string `json:"groupID"`
|
||||
RecvMsgOpt int32 `json:"recvMsgOpt"`
|
||||
UnreadCount int32 `json:"unreadCount"`
|
||||
RecvMsgOpt int32 `json:"recvMsgOpt" binding:"omitempty,oneof=0 1 2"`
|
||||
UnreadCount int32 `json:"unreadCount" binding:"omitempty"`
|
||||
DraftTextTime int64 `json:"draftTextTime"`
|
||||
IsPinned bool `json:"isPinned"`
|
||||
IsPinned bool `json:"isPinned" binding:"omitempty"`
|
||||
IsPrivateChat bool `json:"isPrivateChat"`
|
||||
AttachedInfo string `json:"attachedInfo"`
|
||||
Ex string `json:"ex"`
|
||||
@ -49,7 +49,7 @@ type Conversation struct {
|
||||
|
||||
type SetConversationReq struct {
|
||||
Conversation
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type SetConversationResp struct {
|
||||
@ -58,13 +58,13 @@ type SetConversationResp struct {
|
||||
|
||||
type BatchSetConversationsReq struct {
|
||||
Conversations []Conversation `json:"conversations" binding:"required"`
|
||||
OwnerUserID string `json:"ownerUserID" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
OwnerUserID string `json:"ownerUserID" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type BatchSetConversationsResp struct {
|
||||
CommResp
|
||||
Data struct{
|
||||
Data struct {
|
||||
Success []string `json:"success"`
|
||||
Failed []string `json:"failed"`
|
||||
} `json:"data"`
|
||||
@ -93,11 +93,22 @@ type GetAllConversationsResp struct {
|
||||
|
||||
type GetConversationsReq struct {
|
||||
ConversationIDs []string `json:"conversationIDs" binding:"required"`
|
||||
OwnerUserID string `json:"ownerUserID" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
OwnerUserID string `json:"ownerUserID" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type GetConversationsResp struct {
|
||||
CommResp
|
||||
Conversations []Conversation `json:"data"`
|
||||
}
|
||||
}
|
||||
|
||||
type SetRecvMsgOptReq struct {
|
||||
OwnerUserID string `json:"ownerUserID" binding:"required"`
|
||||
ConversationID string `json:"conversationID"`
|
||||
RecvMsgOpt int32 `json:"recvMsgOpt" binding:"omitempty,oneof=0 1 2"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type SetRecvMsgOptResp struct {
|
||||
CommResp
|
||||
}
|
||||
|
@ -125,7 +125,6 @@ func (d *DataBases) GetMsgBySeqList(uid string, seqList []uint32, operationID st
|
||||
return seqMsg, nil
|
||||
}
|
||||
|
||||
|
||||
func (d *DataBases) GetMsgBySeqListMongo2(uid string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, err error) {
|
||||
var hasSeqList []uint32
|
||||
singleCount := 0
|
||||
@ -178,7 +177,6 @@ func (d *DataBases) GetMsgBySeqListMongo2(uid string, seqList []uint32, operatio
|
||||
return seqMsg, nil
|
||||
}
|
||||
|
||||
|
||||
func genExceptionMessageBySeqList(seqList []uint32) (exceptionMsg []*open_im_sdk.MsgData) {
|
||||
for _, v := range seqList {
|
||||
msg := new(open_im_sdk.MsgData)
|
||||
@ -199,7 +197,7 @@ func (d *DataBases) SaveUserChatMongo2(uid string, sendTime int64, m *pbMsg.MsgD
|
||||
sMsg := MsgInfo{}
|
||||
sMsg.SendTime = sendTime
|
||||
if sMsg.Msg, err = proto.Marshal(m.MsgData); err != nil {
|
||||
return utils.Wrap(err,"")
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
err = c.FindOneAndUpdate(ctx, filter, bson.M{"$push": bson.M{"msg": sMsg}}).Err()
|
||||
log.NewDebug(operationID, "get mgoSession cost time", getCurrentTimestampByMill()-newTime)
|
||||
@ -207,11 +205,11 @@ func (d *DataBases) SaveUserChatMongo2(uid string, sendTime int64, m *pbMsg.MsgD
|
||||
sChat := UserChat{}
|
||||
sChat.UID = seqUid
|
||||
sChat.Msg = append(sChat.Msg, sMsg)
|
||||
if _, err = c.InsertOne(ctx, &sChat) ; err != nil{
|
||||
if _, err = c.InsertOne(ctx, &sChat); err != nil {
|
||||
log.NewDebug(operationID, "InsertOne failed", filter)
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
log.NewDebug(operationID, "FindOneAndUpdate ok", filter)
|
||||
}
|
||||
|
||||
@ -258,7 +256,6 @@ func (d *DataBases) SaveUserChat(uid string, sendTime int64, m *pbMsg.MsgDataToD
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
func (d *DataBases) DelUserChat(uid string) error {
|
||||
return nil
|
||||
//session := d.mgoSession.Clone()
|
||||
@ -277,7 +274,6 @@ func (d *DataBases) DelUserChat(uid string) error {
|
||||
//return nil
|
||||
}
|
||||
|
||||
|
||||
func (d *DataBases) DelUserChatMongo2(uid string) error {
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
||||
@ -290,8 +286,6 @@ func (d *DataBases) DelUserChatMongo2(uid string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (d *DataBases) MgoUserCount() (int, error) {
|
||||
return 0, nil
|
||||
//session := d.mgoSession.Clone()
|
||||
|
@ -307,11 +307,30 @@ func SetConversation(conversation db.Conversation) error {
|
||||
} else {
|
||||
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "exist in db, update")
|
||||
//force update
|
||||
return dbConn.Model(&db.Conversation{}).Update(conversation).
|
||||
return dbConn.Model(conversation).Where("owner_user_id = ? and conversation_id = ?", conversation.OwnerUserID, conversation.ConversationID).
|
||||
Update(map[string]interface{}{"recv_msg_opt": conversation.RecvMsgOpt, "is_pinned": conversation.IsPinned, "is_private_chat": conversation.IsPrivateChat}).Error
|
||||
}
|
||||
}
|
||||
|
||||
func SetRecvMsgOpt(conversation db.Conversation) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dbConn.LogMode(true)
|
||||
newConversation := conversation
|
||||
if dbConn.Model(&db.Conversation{}).Find(&newConversation).RowsAffected == 0 {
|
||||
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "not exist in db, create")
|
||||
return dbConn.Model(&db.Conversation{}).Create(conversation).Error
|
||||
// if exist, then update record
|
||||
} else {
|
||||
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "exist in db, update")
|
||||
//force update
|
||||
return dbConn.Model(conversation).Where("owner_user_id = ? and conversation_id = ?", conversation.OwnerUserID, conversation.ConversationID).
|
||||
Update(map[string]interface{}{"recv_msg_opt": conversation.RecvMsgOpt}).Error
|
||||
}
|
||||
}
|
||||
|
||||
func GetUserAllConversations(ownerUserID string) ([]db.Conversation, error) {
|
||||
var conversations []db.Conversation
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
@ -330,7 +349,7 @@ func GetConversation(OwnerUserID, conversationID string) (db.Conversation, error
|
||||
return conversation, err
|
||||
}
|
||||
err = dbConn.Model(&db.Conversation{
|
||||
OwnerUserID: OwnerUserID,
|
||||
OwnerUserID: OwnerUserID,
|
||||
ConversationID: conversationID,
|
||||
}).Find(&conversation).Error
|
||||
return conversation, err
|
||||
@ -344,4 +363,4 @@ func GetConversations(OwnerUserID string, conversationIDs []string) ([]db.Conver
|
||||
}
|
||||
err = dbConn.Model(&db.Conversation{}).Where("conversation_id IN (?) and owner_user_id=?", conversationIDs, OwnerUserID).Find(&conversations).Error
|
||||
return conversations, err
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -91,6 +91,17 @@ message SetConversationResp{
|
||||
CommonResp commonResp = 1;
|
||||
}
|
||||
|
||||
message SetRecvMsgOptReq {
|
||||
string OwnerUserID = 1;
|
||||
string ConversationID = 2;
|
||||
int32 RecvMsgOpt = 3;
|
||||
string OperationID = 4;
|
||||
}
|
||||
|
||||
message SetRecvMsgOptResp {
|
||||
CommonResp commonResp = 1;
|
||||
}
|
||||
|
||||
message GetConversationReq{
|
||||
string ConversationID = 1;
|
||||
string OwnerUserID = 2;
|
||||
@ -272,6 +283,8 @@ message DeleteUserResp {
|
||||
CommonResp CommonResp = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
service user {
|
||||
rpc GetUserInfo(GetUserInfoReq) returns(GetUserInfoResp);
|
||||
rpc UpdateUserInfo(UpdateUserInfoReq) returns(UpdateUserInfoResp);
|
||||
@ -284,6 +297,7 @@ service user {
|
||||
rpc GetConversations(GetConversationsReq)returns(GetConversationsResp);
|
||||
rpc BatchSetConversations(BatchSetConversationsReq)returns(BatchSetConversationsResp);
|
||||
rpc SetConversation(SetConversationReq)returns(SetConversationResp);
|
||||
rpc SetRecvMsgOpt(SetRecvMsgOptReq)returns(SetRecvMsgOptResp);
|
||||
|
||||
rpc GetUserById(GetUserByIdReq) returns (GetUserByIdResp);
|
||||
rpc GetUsersByName(GetUsersByNameReq) returns (GetUsersByNameResp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user