mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-06-26 04:08:11 +08:00
单向删除好友
This commit is contained in:
parent
66368cdd27
commit
60d6e6ef01
@ -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)
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -893,4 +893,3 @@ func (c *conversationServer) ClearBurnExpiredMsgs(ctx context.Context, req *pbco
|
||||
}
|
||||
return &pbconversation.ClearBurnExpiredMsgsResp{Count: processed}, nil
|
||||
}
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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",
|
||||
|
||||
2
protocol
2
protocol
@ -1 +1 @@
|
||||
Subproject commit a9d1f9d497b399e9c1bc9bcf7b752a24c15959ec
|
||||
Subproject commit 9e40541a87bb803959895e635a1923f4a6550952
|
||||
Loading…
x
Reference in New Issue
Block a user