mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Refactor code
This commit is contained in:
parent
348ce56776
commit
f0c5b1e544
@ -144,6 +144,7 @@ func (s *friendServer) AddFriend(ctx context.Context, req *pbFriend.AddFriendReq
|
||||
//Establish a latest relationship in the friend request table
|
||||
friendRequest := imdb.FriendRequest{ReqMsg: req.ReqMsg}
|
||||
utils.CopyStructFields(&friendRequest, req.CommID)
|
||||
// {openIM001 openIM002 0 test add friend 0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC }]
|
||||
log.NewDebug(req.CommID.OperationID, "UpdateFriendApplication args ", friendRequest)
|
||||
err := imdb.UpdateFriendApplication(&friendRequest)
|
||||
if err != nil {
|
||||
|
@ -65,11 +65,10 @@ func UpdateFriendApplication(friendRequest *FriendRequest) error {
|
||||
return err
|
||||
}
|
||||
friendRequest.CreateTime = time.Now()
|
||||
err = dbConn.Table("friend_request").Where("from_user_id=? and to_user_id=?", friendRequest.FromUserID, friendRequest.ToUserID).Update(&friendRequest).Error
|
||||
if err != nil {
|
||||
return err
|
||||
if dbConn.Table("friend_request").Where("from_user_id=? and to_user_id=?",
|
||||
friendRequest.FromUserID, friendRequest.ToUserID).Update(&friendRequest).RowsAffected == 0 {
|
||||
return InsertFriendApplication(friendRequest)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func InsertFriendApplication(friendRequest *FriendRequest) error {
|
||||
|
Loading…
x
Reference in New Issue
Block a user