add friend and blacklist judge

pull/218/head
Gordon 3 years ago
parent 10884b8175
commit 852d3b9f48

@ -56,10 +56,9 @@ func userRelationshipVerification(data *pbChat.SendMsgReq) (bool, int32, string)
reply, err := client.IsInBlackList(context.Background(), req)
if err != nil {
log.NewDebug(data.OperationID, "IsInBlackListReq rpc failed, ", req.String(), err.Error())
return false, 600, err.Error()
} else if reply.Response == false {
} else if reply.Response == true {
log.NewDebug(data.OperationID, "IsInBlackListReq ", req.String())
return reply.Response, 600, "in black list"
return false, 600, "in black list"
}
if config.Config.MessageVerify.FriendVerify {
friendReq := &rpc.IsFriendReq{CommID: &rpc.CommID{}}
@ -70,7 +69,7 @@ func userRelationshipVerification(data *pbChat.SendMsgReq) (bool, int32, string)
friendReply, err := client.IsFriend(context.Background(), friendReq)
if err != nil {
log.NewDebug(data.OperationID, "IsFriendReq rpc failed, ", req.String(), err.Error())
return false, 601, err.Error()
return true, 0, ""
} else if friendReply.Response == false {
log.NewDebug(data.OperationID, "not friend ", req.String())
return friendReply.Response, 601, "not friend"
@ -130,10 +129,10 @@ func (rpc *rpcChat) encapsulateMsgData(msg *sdk_ws.MsgData) {
func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.SendMsgResp, error) {
replay := pbChat.SendMsgResp{}
log.NewDebug(pb.OperationID, "rpc sendMsg come here", pb.String())
//flag, errCode, errMsg := userRelationshipVerification(pb)
//if !flag {
// return returnMsg(&replay, pb, errCode, errMsg, "", 0)
//}
flag, errCode, errMsg := userRelationshipVerification(pb)
if !flag {
return returnMsg(&replay, pb, errCode, errMsg, "", 0)
}
//if !utils.VerifyToken(pb.Token, pb.SendID) {
// return returnMsg(&replay, pb, http.StatusUnauthorized, "token validate err,not authorized", "", 0)
rpc.encapsulateMsgData(pb.MsgData)

Loading…
Cancel
Save