From 415d40f8c503d98b9922768d00a7b53dd2271d32 Mon Sep 17 00:00:00 2001 From: WangchuXiao Date: Thu, 10 Aug 2023 20:12:37 +0800 Subject: [PATCH] Fix bug: first time add friend (#844) * new feature: add batch send msg * new feature: add batch send msg * new feature: add batch send msg * new feature: add batch send msg * new feature: add batch send msg * new feature: add batch send msg * fix bug: multiple gateway kick user * fix bug: multiple gateway kick user * fix bug: multiple gateway kick user * fix bug: multiple gateway kick user * fix bug: multiple gateway kick user * MsgDestructTime * fix bug: msg destruct sql * fix bug: msg destruct * fix bug: msg destruct * fix bug: msg destruct sql * fix bug: msg destruct sql * fix bug: msg destruct sql * fix bug: msg destruct sql * debug: print stack * debug: print stack * debug: print stack * fix bug: msg destruct sql Signed-off-by: wangchuxiao * fix bug: msg notification self 2 self push twice * fix bug: heartbeat get self notification * fix bug: init grpc conn in one process * fix bug: grpc conn Signed-off-by: wangchuxiao * fix bug: zk client recreate node when reconn * fix bug: set friend mark args error * fix bug: rpc client intercepter called twice Signed-off-by: wangchuxiao * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * test: document msg num set 100 * new feat: sync designated model * new feat: sync designated model * new feat: sync designated model * new feat: sync designated model * new feat: sync designated model * new feat: sync designated model * new feat: sync designated model * merge code * merge code * fix bug: repeat add friend not effect * fix bug: refused friend * fix bug: fix_add_friend * fix bug: fix_add_friend * fix bug: fix_add_friend --------- Signed-off-by: wangchuxiao Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: wangchuxiao-dev --- pkg/common/db/controller/friend.go | 1 + pkg/common/db/relation/friend_request_model.go | 6 +++++- pkg/common/db/relation/meta_db.go | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/common/db/controller/friend.go b/pkg/common/db/controller/friend.go index 69db8dd6e..a1cb547bf 100644 --- a/pkg/common/db/controller/friend.go +++ b/pkg/common/db/controller/friend.go @@ -209,6 +209,7 @@ func (f *friendDatabase) RefuseFriendRequest( if fr.HandleResult != 0 { return errs.ErrArgs.Wrap("the friend request has been processed") } + log.ZDebug(ctx, "refuse friend request", "friendRequest db", fr, "friendRequest arg", friendRequest) friendRequest.HandleResult = constant.FriendResponseRefuse friendRequest.HandleTime = time.Now() err = f.friendRequest.Update(ctx, friendRequest) diff --git a/pkg/common/db/relation/friend_request_model.go b/pkg/common/db/relation/friend_request_model.go index 0abb06b44..7a1f98715 100644 --- a/pkg/common/db/relation/friend_request_model.go +++ b/pkg/common/db/relation/friend_request_model.go @@ -71,9 +71,13 @@ func (f *FriendRequestGorm) UpdateByMap( // 更新记录 (非零值). func (f *FriendRequestGorm) Update(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) { + fromUserID := friendRequest.FromUserID + toUserID := friendRequest.ToUserID + friendRequest.FromUserID = "" + friendRequest.ToUserID = "" return utils.Wrap( f.db(ctx). - Where("from_user_id = ? AND to_user_id =?", friendRequest.FromUserID, friendRequest.ToUserID). + Where("from_user_id = ? AND to_user_id =?", fromUserID, toUserID). Updates(friendRequest). Error, "", diff --git a/pkg/common/db/relation/meta_db.go b/pkg/common/db/relation/meta_db.go index 60e4a5464..6ab980120 100644 --- a/pkg/common/db/relation/meta_db.go +++ b/pkg/common/db/relation/meta_db.go @@ -33,5 +33,6 @@ func NewMetaDB(db *gorm.DB, table any) *MetaDB { } func (g *MetaDB) db(ctx context.Context) *gorm.DB { - return g.DB.WithContext(ctx).Model(g.table) + db := g.DB.WithContext(ctx).Model(g.table) + return db }