friend relationship insert --->replace

pull/4/head
away 4 years ago
parent c5c8bef5f9
commit 2529312a1d

@ -11,7 +11,6 @@ import (
"Open_IM/src/push/logic"
"Open_IM/src/utils"
"context"
"fmt"
)
func (s *friendServer) AddFriend(ctx context.Context, req *pbFriend.AddFriendReq) (*pbFriend.CommonResp, error) {
@ -22,10 +21,10 @@ func (s *friendServer) AddFriend(ctx context.Context, req *pbFriend.AddFriendReq
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
return &pbFriend.CommonResp{ErrorCode: config.ErrParseToken.ErrCode, ErrorMsg: config.ErrParseToken.ErrMsg}, nil
}
//Establish a relationship in the friend request table
err = im_mysql_model.InsertIntoFriendReq(claims.UID, req.Uid, constant.NotFriendFlag, req.ReqMessage)
//Establish a latest relationship in the friend request table
err = im_mysql_model.ReplaceIntoFriendReq(claims.UID, req.Uid, constant.NotFriendFlag, req.ReqMessage)
if err != nil {
log.Error(req.Token, req.OperationID, fmt.Sprintf("err=%s,create friend request ship failed", err.Error()))
log.Error(req.Token, req.OperationID, "err=%s,create friend request ship failed", err.Error())
return &pbFriend.CommonResp{ErrorCode: config.ErrAddFriend.ErrCode, ErrorMsg: config.ErrAddFriend.ErrMsg}, nil
}
log.Info(req.Token, req.OperationID, "rpc add friend is success return,uid=%s", req.Uid)

Loading…
Cancel
Save