diff --git a/internal/api/friend.go b/internal/api/friend.go index 14bce2388..fc09c77e9 100644 --- a/internal/api/friend.go +++ b/internal/api/friend.go @@ -41,6 +41,10 @@ func (o *FriendApi) DeleteFriend(c *gin.Context) { a2r.Call(c, relation.FriendClient.DeleteFriend, o.Client) } +func (o *FriendApi) DeleteFriendOneway(c *gin.Context) { + a2r.Call(c, relation.FriendClient.DeleteFriendOneway, o.Client) +} + func (o *FriendApi) GetFriendApplyList(c *gin.Context) { a2r.Call(c, relation.FriendClient.GetPaginationFriendsApplyTo, o.Client) } diff --git a/internal/api/router.go b/internal/api/router.go index c681b8208..dbaee2184 100644 --- a/internal/api/router.go +++ b/internal/api/router.go @@ -198,6 +198,7 @@ func newGinRouter(ctx context.Context, client discovery.SvcDiscoveryRegistry, co f := NewFriendApi(relation.NewFriendClient(friendConn)) friendRouterGroup := r.Group("/friend") friendRouterGroup.POST("/delete_friend", f.DeleteFriend) + friendRouterGroup.POST("/delete_friend_oneway", f.DeleteFriendOneway) friendRouterGroup.POST("/get_friend_apply_list", f.GetFriendApplyList) friendRouterGroup.POST("/get_designated_friend_apply", f.GetDesignatedFriendsApply) friendRouterGroup.POST("/get_self_friend_apply_list", f.GetSelfApplyList) diff --git a/internal/rpc/conversation/conversation.go b/internal/rpc/conversation/conversation.go index 1b86e6b8b..c443bb638 100644 --- a/internal/rpc/conversation/conversation.go +++ b/internal/rpc/conversation/conversation.go @@ -893,4 +893,3 @@ func (c *conversationServer) ClearBurnExpiredMsgs(ctx context.Context, req *pbco } return &pbconversation.ClearBurnExpiredMsgsResp{Count: processed}, nil } - diff --git a/internal/rpc/relation/friend.go b/internal/rpc/relation/friend.go index da6d360ea..556a81cc5 100644 --- a/internal/rpc/relation/friend.go +++ b/internal/rpc/relation/friend.go @@ -286,6 +286,29 @@ func (s *friendServer) DeleteFriend(ctx context.Context, req *relation.DeleteFri return &relation.DeleteFriendResp{}, nil } +// DeleteFriendOneway 单向删除好友:只删除 ownerUserID 侧的 friend 文档; +// 对端 friend 文档保留;仅向 owner 下发 FriendsInfoUpdateNotification 以刷新本地好友列表, +// 不向对端发送 FriendDeletedNotification。 +func (s *friendServer) DeleteFriendOneway(ctx context.Context, req *relation.DeleteFriendReq) (resp *relation.DeleteFriendResp, err error) { + if err := authverify.CheckAccessV3(ctx, req.OwnerUserID, s.config.Share.IMAdminUserID); err != nil { + return nil, err + } + + _, err = s.db.FindFriendsWithError(ctx, req.OwnerUserID, []string{req.FriendUserID}) + if err != nil { + return nil, err + } + + if err := s.db.Delete(ctx, req.OwnerUserID, []string{req.FriendUserID}); err != nil { + return nil, err + } + + s.notificationSender.FriendDeletedOnewayNotification(ctx, req.OwnerUserID, req.FriendUserID) + s.webhookAfterDeleteFriend(ctx, &s.config.WebhooksConfig.AfterDeleteFriend, req) + + return &relation.DeleteFriendResp{}, nil +} + // ok. func (s *friendServer) SetFriendRemark(ctx context.Context, req *relation.SetFriendRemarkReq) (resp *relation.SetFriendRemarkResp, err error) { if err = s.webhookBeforeSetFriendRemark(ctx, &s.config.WebhooksConfig.BeforeSetFriendRemark, req); err != nil && err != servererrs.ErrCallbackContinue { diff --git a/internal/rpc/relation/notification.go b/internal/rpc/relation/notification.go index d9d773c76..10f7e7736 100644 --- a/internal/rpc/relation/notification.go +++ b/internal/rpc/relation/notification.go @@ -241,6 +241,18 @@ func (f *FriendNotificationSender) FriendDeletedNotification(ctx context.Context f.Notification(ctx, req.OwnerUserID, req.FriendUserID, constant.FriendDeletedNotification, &tips) } +// FriendDeletedOnewayNotification 单向删好友:仅通知操作方本人刷新好友列表, +// 不向对端发送 FriendDeletedNotification,对端仍保留「你是 TA 好友」的关系。 +func (f *FriendNotificationSender) FriendDeletedOnewayNotification(ctx context.Context, ownerUserID, friendUserID string) { + tips := sdkws.FriendsInfoUpdateTips{ + FromToUserID: &sdkws.FromToUserID{ToUserID: ownerUserID}, + FriendIDs: []string{friendUserID}, + } + f.setSortVersion(ctx, &tips.FriendVersion, &tips.FriendVersionID, + database.FriendVersionName, ownerUserID, &tips.FriendSortVersion) + f.Notification(ctx, ownerUserID, ownerUserID, constant.FriendsInfoUpdateNotification, &tips) +} + func (f *FriendNotificationSender) setVersion(ctx context.Context, version *uint64, versionID *string, collName string, id string) { versions := versionctx.GetVersionLog(ctx).Get() for _, coll := range versions { diff --git a/pkg/common/storage/database/mgo/user.go b/pkg/common/storage/database/mgo/user.go index 25044cb1d..cf7e3479a 100644 --- a/pkg/common/storage/database/mgo/user.go +++ b/pkg/common/storage/database/mgo/user.go @@ -82,7 +82,6 @@ func (u *UserMgo) UpdateByMap(ctx context.Context, userID string, args map[strin "first_name", "last_name", "full_name", - "remark", "face_url", "phone_number", "area_code", diff --git a/protocol b/protocol index a9d1f9d49..9e40541a8 160000 --- a/protocol +++ b/protocol @@ -1 +1 @@ -Subproject commit a9d1f9d497b399e9c1bc9bcf7b752a24c15959ec +Subproject commit 9e40541a87bb803959895e635a1923f4a6550952