diff --git a/pkg/common/db/mysql_model/im_mysql_model/friend_request_model.go b/pkg/common/db/mysql_model/im_mysql_model/friend_request_model.go index 2591426a2..0aeb2967e 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/friend_request_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/friend_request_model.go @@ -76,6 +76,14 @@ func InsertFriendApplication(friendRequest *db.FriendRequest) error { if err != nil { return err } + + friendRequest.CreateTime = time.Now() + u := dbConn.Table("friend_requests").Where("from_user_id=? and to_user_id=?", + friendRequest.FromUserID, friendRequest.ToUserID).Update(&friendRequest) + if u.RowsAffected != 0 { + return nil + } + if friendRequest.CreateTime.Unix() < 0 { friendRequest.CreateTime = time.Now() } diff --git a/pkg/common/db/mysql_model/im_mysql_model/group_request_model.go b/pkg/common/db/mysql_model/im_mysql_model/group_request_model.go index 84988a3f4..a4e3ab37f 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/group_request_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/group_request_model.go @@ -36,6 +36,14 @@ func InsertIntoGroupRequest(toInsertInfo db.GroupRequest) error { return err } + if toInsertInfo.HandledTime.Unix() < 0 { + toInsertInfo.HandledTime = utils.UnixSecondToTime(0) + } + u := dbConn.Table("group_requests").Where("group_id=? and user_id=?", toInsertInfo.GroupID, toInsertInfo.UserID).Update(&toInsertInfo) + if u.RowsAffected != 0 { + return nil + } + toInsertInfo.ReqTime = time.Now() if toInsertInfo.HandledTime.Unix() < 0 { toInsertInfo.HandledTime = utils.UnixSecondToTime(0)