|
|
@ -6,9 +6,9 @@ import (
|
|
|
|
"Open_IM/pkg/common/db"
|
|
|
|
"Open_IM/pkg/common/db"
|
|
|
|
"Open_IM/pkg/common/log"
|
|
|
|
"Open_IM/pkg/common/log"
|
|
|
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
|
|
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
|
|
|
|
|
|
|
cacheRpc "Open_IM/pkg/proto/cache"
|
|
|
|
pbChat "Open_IM/pkg/proto/chat"
|
|
|
|
pbChat "Open_IM/pkg/proto/chat"
|
|
|
|
pbConversation "Open_IM/pkg/proto/conversation"
|
|
|
|
pbConversation "Open_IM/pkg/proto/conversation"
|
|
|
|
rpc "Open_IM/pkg/proto/friend"
|
|
|
|
|
|
|
|
pbGroup "Open_IM/pkg/proto/group"
|
|
|
|
pbGroup "Open_IM/pkg/proto/group"
|
|
|
|
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
|
|
|
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
|
|
|
"Open_IM/pkg/utils"
|
|
|
|
"Open_IM/pkg/utils"
|
|
|
@ -48,36 +48,38 @@ func userRelationshipVerification(data *pbChat.SendMsgReq) (bool, int32, string)
|
|
|
|
return true, 0, ""
|
|
|
|
return true, 0, ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.NewDebug(data.OperationID, config.Config.MessageVerify.FriendVerify)
|
|
|
|
log.NewDebug(data.OperationID, config.Config.MessageVerify.FriendVerify)
|
|
|
|
req := &rpc.IsInBlackListReq{CommID: &rpc.CommID{}}
|
|
|
|
reqGetBlackIDListFromCache := &cacheRpc.GetBlackIDListFromCacheReq{UserID: data.MsgData.RecvID, OperationID: data.OperationID}
|
|
|
|
req.CommID.OperationID = data.OperationID
|
|
|
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
|
|
|
|
req.CommID.OpUserID = data.MsgData.RecvID
|
|
|
|
cacheClient := cacheRpc.NewCacheClient(etcdConn)
|
|
|
|
req.CommID.FromUserID = data.MsgData.RecvID
|
|
|
|
cacheResp, err := cacheClient.GetBlackIDListFromCache(context.Background(), reqGetBlackIDListFromCache)
|
|
|
|
req.CommID.ToUserID = data.MsgData.SendID
|
|
|
|
|
|
|
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
|
|
|
|
|
|
|
client := rpc.NewFriendClient(etcdConn)
|
|
|
|
|
|
|
|
reply, err := client.IsInBlackList(context.Background(), req)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.NewDebug(data.OperationID, "IsInBlackListReq rpc failed, ", req.String(), err.Error())
|
|
|
|
log.NewError(data.OperationID, "GetBlackIDListFromCache rpc call failed ", err.Error())
|
|
|
|
} else if reply.Response == true {
|
|
|
|
} else {
|
|
|
|
log.NewDebug(data.OperationID, "IsInBlackListReq ", req.String())
|
|
|
|
if cacheResp.CommonResp.ErrCode != 0 {
|
|
|
|
return false, 600, "in black list"
|
|
|
|
log.NewError(data.OperationID, "GetBlackIDListFromCache rpc logic call failed ", cacheResp.String())
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if utils.IsContain(data.MsgData.SendID, cacheResp.UserIDList) {
|
|
|
|
|
|
|
|
return false, 600, "in black list"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.NewDebug(data.OperationID, config.Config.MessageVerify.FriendVerify)
|
|
|
|
log.NewDebug(data.OperationID, config.Config.MessageVerify.FriendVerify)
|
|
|
|
if config.Config.MessageVerify.FriendVerify {
|
|
|
|
if config.Config.MessageVerify.FriendVerify {
|
|
|
|
friendReq := &rpc.IsFriendReq{CommID: &rpc.CommID{}}
|
|
|
|
reqGetFriendIDListFromCache := &cacheRpc.GetFriendIDListFromCacheReq{UserID: data.MsgData.RecvID, OperationID: data.OperationID}
|
|
|
|
friendReq.CommID.OperationID = data.OperationID
|
|
|
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
|
|
|
|
friendReq.CommID.OpUserID = data.MsgData.RecvID
|
|
|
|
cacheClient := cacheRpc.NewCacheClient(etcdConn)
|
|
|
|
friendReq.CommID.FromUserID = data.MsgData.RecvID
|
|
|
|
cacheResp, err := cacheClient.GetFriendIDListFromCache(context.Background(), reqGetFriendIDListFromCache)
|
|
|
|
friendReq.CommID.ToUserID = data.MsgData.SendID
|
|
|
|
|
|
|
|
friendReply, err := client.IsFriend(context.Background(), friendReq)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.NewDebug(data.OperationID, "IsFriendReq rpc failed, ", req.String(), err.Error())
|
|
|
|
log.NewError(data.OperationID, "GetFriendIDListFromCache rpc call failed ", err.Error())
|
|
|
|
return true, 0, ""
|
|
|
|
} else {
|
|
|
|
} else if friendReply.Response == false {
|
|
|
|
if cacheResp.CommonResp.ErrCode != 0 {
|
|
|
|
log.NewDebug(data.OperationID, "not friend ", req.String())
|
|
|
|
log.NewError(data.OperationID, "GetFriendIDListFromCache rpc logic call failed ", cacheResp.String())
|
|
|
|
return friendReply.Response, 601, "not friend"
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if !utils.IsContain(data.MsgData.SendID, cacheResp.UserIDList) {
|
|
|
|
|
|
|
|
return false, 601, "not friend"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.NewDebug(data.OperationID, config.Config.MessageVerify.FriendVerify, friendReply.Response)
|
|
|
|
|
|
|
|
return true, 0, ""
|
|
|
|
return true, 0, ""
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return true, 0, ""
|
|
|
|
return true, 0, ""
|
|
|
|