mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Check the friend relationship before agreeing to add a friend
This commit is contained in:
parent
2529312a1d
commit
9e2319c8fd
@ -28,7 +28,12 @@ func (s *friendServer) AddedFriend(ctx context.Context, req *pbFriend.AddedFrien
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "rpc add friend response success return,userid=%s,flag=%d", req.Uid, req.Flag)
|
||||
//Change the status of the friend request form
|
||||
if req.Flag == 1 {
|
||||
if req.Flag == constant.FriendFlag {
|
||||
//Establish friendship after find friend relationship not exists
|
||||
_, err := im_mysql_model.FindFriendRelationshipFromFriend(claims.UID, req.Uid)
|
||||
if err == nil {
|
||||
return &pbFriend.CommonResp{ErrorCode: 0, ErrorMsg: "You are already friends"}, nil
|
||||
}
|
||||
//Establish two single friendship
|
||||
err = im_mysql_model.InsertToFriend(claims.UID, req.Uid, req.Flag)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user