mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-29 05:38:45 +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
|
//Establish a latest relationship in the friend request table
|
||||||
friendRequest := imdb.FriendRequest{ReqMsg: req.ReqMsg}
|
friendRequest := imdb.FriendRequest{ReqMsg: req.ReqMsg}
|
||||||
utils.CopyStructFields(&friendRequest, req.CommID)
|
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)
|
log.NewDebug(req.CommID.OperationID, "UpdateFriendApplication args ", friendRequest)
|
||||||
err := imdb.UpdateFriendApplication(&friendRequest)
|
err := imdb.UpdateFriendApplication(&friendRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -65,11 +65,10 @@ func UpdateFriendApplication(friendRequest *FriendRequest) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
friendRequest.CreateTime = time.Now()
|
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 dbConn.Table("friend_request").Where("from_user_id=? and to_user_id=?",
|
||||||
if err != nil {
|
friendRequest.FromUserID, friendRequest.ToUserID).Update(&friendRequest).RowsAffected == 0 {
|
||||||
return err
|
return InsertFriendApplication(friendRequest)
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func InsertFriendApplication(friendRequest *FriendRequest) error {
|
func InsertFriendApplication(friendRequest *FriendRequest) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user