|
|
|
@ -293,7 +293,6 @@ func (s *friendServer) ImportFriend(ctx context.Context, req *pbFriend.ImportFri
|
|
|
|
|
//process Friend application
|
|
|
|
|
func (s *friendServer) AddFriendResponse(ctx context.Context, req *pbFriend.AddFriendResponseReq) (*pbFriend.AddFriendResponseResp, error) {
|
|
|
|
|
log.NewInfo(req.CommID.OperationID, "AddFriendResponse args ", req.String())
|
|
|
|
|
|
|
|
|
|
if !token_verify.CheckAccess(req.CommID.OpUserID, req.CommID.FromUserID) {
|
|
|
|
|
log.NewError(req.CommID.OperationID, "CheckAccess false ", req.CommID.OpUserID, req.CommID.FromUserID)
|
|
|
|
|
return &pbFriend.AddFriendResponseResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
|
|
|
@ -319,6 +318,7 @@ func (s *friendServer) AddFriendResponse(ctx context.Context, req *pbFriend.AddF
|
|
|
|
|
|
|
|
|
|
//Change the status of the friend request form
|
|
|
|
|
if req.HandleResult == constant.FriendFlag {
|
|
|
|
|
var isInsert int
|
|
|
|
|
//Establish friendship after find friend relationship not exists
|
|
|
|
|
_, err := imdb.GetFriendRelationshipFromFriend(req.CommID.FromUserID, req.CommID.ToUserID)
|
|
|
|
|
if err == nil {
|
|
|
|
@ -331,6 +331,7 @@ func (s *friendServer) AddFriendResponse(ctx context.Context, req *pbFriend.AddF
|
|
|
|
|
log.NewError(req.CommID.OperationID, "InsertToFriend failed ", err.Error(), toInsertFollow)
|
|
|
|
|
return &pbFriend.AddFriendResponseResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
|
|
|
|
}
|
|
|
|
|
isInsert = 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, err = imdb.GetFriendRelationshipFromFriend(req.CommID.ToUserID, req.CommID.FromUserID)
|
|
|
|
@ -343,7 +344,10 @@ func (s *friendServer) AddFriendResponse(ctx context.Context, req *pbFriend.AddF
|
|
|
|
|
log.NewError(req.CommID.OperationID, "InsertToFriend failed ", err.Error(), toInsertFollow)
|
|
|
|
|
return &pbFriend.AddFriendResponseResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
|
|
|
|
}
|
|
|
|
|
// cache rpc
|
|
|
|
|
isInsert = 1
|
|
|
|
|
}
|
|
|
|
|
// cache rpc
|
|
|
|
|
if isInsert == 1 {
|
|
|
|
|
delFriendIDListFromCacheReq := &pbCache.DelFriendIDListFromCacheReq{OperationID: req.CommID.OperationID}
|
|
|
|
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.CommID.OperationID)
|
|
|
|
|
if etcdConn == nil {
|
|
|
|
|