mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-11-04 11:22:10 +08:00 
			
		
		
		
	refactor: replace friend package with realtion.
				
					
				
			This commit is contained in:
		
							parent
							
								
									1b5621bc09
								
							
						
					
					
						commit
						1796c3a9e4
					
				
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							@ -13,7 +13,7 @@ require (
 | 
			
		||||
	github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
 | 
			
		||||
	github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible // indirect
 | 
			
		||||
	github.com/mitchellh/mapstructure v1.5.0
 | 
			
		||||
	github.com/openimsdk/protocol v0.0.69-alpha.3
 | 
			
		||||
	github.com/openimsdk/protocol v0.0.69-alpha.4
 | 
			
		||||
	github.com/openimsdk/tools v0.0.49-alpha.24
 | 
			
		||||
	github.com/pkg/errors v0.9.1 // indirect
 | 
			
		||||
	github.com/prometheus/client_golang v1.18.0
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.sum
									
									
									
									
									
								
							@ -288,6 +288,8 @@ github.com/openimsdk/gomake v0.0.13 h1:xLDe/moqgWpRoptHzI4packAWzs4C16b+sVY+txNJ
 | 
			
		||||
github.com/openimsdk/gomake v0.0.13/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
 | 
			
		||||
github.com/openimsdk/protocol v0.0.69-alpha.3 h1:Uf167FVB5EqYpiy2zBbR63OiK+Njjy99fXYasK6Zi+4=
 | 
			
		||||
github.com/openimsdk/protocol v0.0.69-alpha.3/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8=
 | 
			
		||||
github.com/openimsdk/protocol v0.0.69-alpha.4 h1:QJkOFV5Hlu7CbkHG5smeVw+5fx5DVkpNJWqlAOJxuIY=
 | 
			
		||||
github.com/openimsdk/protocol v0.0.69-alpha.4/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8=
 | 
			
		||||
github.com/openimsdk/tools v0.0.49-alpha.24 h1:lJsqnjTPujnr91LRQ6QmcTliMIa4fMOBSTri6rFz2ek=
 | 
			
		||||
github.com/openimsdk/tools v0.0.49-alpha.24/go.mod h1:g7mkHXYUPi0/8aAX8VPMHpnb3hqdV69Jph+bXOGvvNM=
 | 
			
		||||
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
 | 
			
		||||
 | 
			
		||||
@ -17,7 +17,7 @@ package api
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/gin-gonic/gin"
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
 | 
			
		||||
	"github.com/openimsdk/protocol/friend"
 | 
			
		||||
	"github.com/openimsdk/protocol/relation"
 | 
			
		||||
	"github.com/openimsdk/tools/a2r"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@ -28,73 +28,77 @@ func NewFriendApi(client rpcclient.Friend) FriendApi {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) ApplyToAddFriend(c *gin.Context) {
 | 
			
		||||
	a2r.Call(friend.FriendClient.ApplyToAddFriend, o.Client, c)
 | 
			
		||||
	a2r.Call(relation.FriendClient.ApplyToAddFriend, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) RespondFriendApply(c *gin.Context) {
 | 
			
		||||
	a2r.Call(friend.FriendClient.RespondFriendApply, o.Client, c)
 | 
			
		||||
	a2r.Call(relation.FriendClient.RespondFriendApply, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) DeleteFriend(c *gin.Context) {
 | 
			
		||||
	a2r.Call(friend.FriendClient.DeleteFriend, o.Client, c)
 | 
			
		||||
	a2r.Call(relation.FriendClient.DeleteFriend, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) GetFriendApplyList(c *gin.Context) {
 | 
			
		||||
	a2r.Call(friend.FriendClient.GetPaginationFriendsApplyTo, o.Client, c)
 | 
			
		||||
	a2r.Call(relation.FriendClient.GetPaginationFriendsApplyTo, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) GetDesignatedFriendsApply(c *gin.Context) {
 | 
			
		||||
	a2r.Call(friend.FriendClient.GetDesignatedFriendsApply, o.Client, c)
 | 
			
		||||
	a2r.Call(relation.FriendClient.GetDesignatedFriendsApply, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) GetSelfApplyList(c *gin.Context) {
 | 
			
		||||
	a2r.Call(friend.FriendClient.GetPaginationFriendsApplyFrom, o.Client, c)
 | 
			
		||||
	a2r.Call(relation.FriendClient.GetPaginationFriendsApplyFrom, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) GetFriendList(c *gin.Context) {
 | 
			
		||||
	a2r.Call(friend.FriendClient.GetPaginationFriends, o.Client, c)
 | 
			
		||||
	a2r.Call(relation.FriendClient.GetPaginationFriends, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) GetDesignatedFriends(c *gin.Context) {
 | 
			
		||||
	a2r.Call(friend.FriendClient.GetDesignatedFriends, o.Client, c)
 | 
			
		||||
	a2r.Call(relation.FriendClient.GetDesignatedFriends, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) SetFriendRemark(c *gin.Context) {
 | 
			
		||||
	a2r.Call(friend.FriendClient.SetFriendRemark, o.Client, c)
 | 
			
		||||
	a2r.Call(relation.FriendClient.SetFriendRemark, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) AddBlack(c *gin.Context) {
 | 
			
		||||
	a2r.Call(friend.FriendClient.AddBlack, o.Client, c)
 | 
			
		||||
	a2r.Call(relation.FriendClient.AddBlack, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) GetPaginationBlacks(c *gin.Context) {
 | 
			
		||||
	a2r.Call(friend.FriendClient.GetPaginationBlacks, o.Client, c)
 | 
			
		||||
	a2r.Call(relation.FriendClient.GetPaginationBlacks, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) RemoveBlack(c *gin.Context) {
 | 
			
		||||
	a2r.Call(friend.FriendClient.RemoveBlack, o.Client, c)
 | 
			
		||||
	a2r.Call(relation.FriendClient.RemoveBlack, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) ImportFriends(c *gin.Context) {
 | 
			
		||||
	a2r.Call(friend.FriendClient.ImportFriends, o.Client, c)
 | 
			
		||||
	a2r.Call(relation.FriendClient.ImportFriends, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) IsFriend(c *gin.Context) {
 | 
			
		||||
	a2r.Call(friend.FriendClient.IsFriend, o.Client, c)
 | 
			
		||||
	a2r.Call(relation.FriendClient.IsFriend, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) GetFriendIDs(c *gin.Context) {
 | 
			
		||||
	a2r.Call(friend.FriendClient.GetFriendIDs, o.Client, c)
 | 
			
		||||
	a2r.Call(relation.FriendClient.GetFriendIDs, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) GetSpecifiedFriendsInfo(c *gin.Context) {
 | 
			
		||||
	a2r.Call(friend.FriendClient.GetSpecifiedFriendsInfo, o.Client, c)
 | 
			
		||||
	a2r.Call(relation.FriendClient.GetSpecifiedFriendsInfo, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) UpdateFriends(c *gin.Context) {
 | 
			
		||||
	a2r.Call(friend.FriendClient.UpdateFriends, o.Client, c)
 | 
			
		||||
	a2r.Call(relation.FriendClient.UpdateFriends, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) GetIncrementalFriends(c *gin.Context) {
 | 
			
		||||
	a2r.Call(friend.FriendClient.GetIncrementalFriends, o.Client, c)
 | 
			
		||||
	a2r.Call(relation.FriendClient.GetIncrementalFriends, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *FriendApi) GetIncrementalBlacks(c *gin.Context) {
 | 
			
		||||
	a2r.Call(relation.FriendClient.GetIncrementalBlacks, o.Client, c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -2,6 +2,9 @@ package api
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"github.com/gin-gonic/gin"
 | 
			
		||||
	"github.com/gin-gonic/gin/binding"
 | 
			
		||||
	"github.com/go-playground/validator/v10"
 | 
			
		||||
@ -14,8 +17,6 @@ import (
 | 
			
		||||
	"github.com/openimsdk/tools/mw"
 | 
			
		||||
	"google.golang.org/grpc"
 | 
			
		||||
	"google.golang.org/grpc/credentials/insecure"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func newGinRouter(disCov discovery.SvcDiscoveryRegistry, config *Config) *gin.Engine {
 | 
			
		||||
@ -81,6 +82,7 @@ func newGinRouter(disCov discovery.SvcDiscoveryRegistry, config *Config) *gin.En
 | 
			
		||||
		friendRouterGroup.POST("/add_black", f.AddBlack)
 | 
			
		||||
		friendRouterGroup.POST("/get_black_list", f.GetPaginationBlacks)
 | 
			
		||||
		friendRouterGroup.POST("/remove_black", f.RemoveBlack)
 | 
			
		||||
		friendRouterGroup.POST("/get_incremental_blacks", f.GetIncrementalBlacks)
 | 
			
		||||
		friendRouterGroup.POST("/import_friend", f.ImportFriends)
 | 
			
		||||
		friendRouterGroup.POST("/is_friend", f.IsFriend)
 | 
			
		||||
		friendRouterGroup.POST("/get_friend_id", f.GetFriendIDs)
 | 
			
		||||
 | 
			
		||||
@ -16,16 +16,17 @@ package friend
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
 | 
			
		||||
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/authverify"
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/common/convert"
 | 
			
		||||
	pbfriend "github.com/openimsdk/protocol/friend"
 | 
			
		||||
	"github.com/openimsdk/protocol/relation"
 | 
			
		||||
	"github.com/openimsdk/tools/mcontext"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) GetPaginationBlacks(ctx context.Context, req *pbfriend.GetPaginationBlacksReq) (resp *pbfriend.GetPaginationBlacksResp, err error) {
 | 
			
		||||
func (s *friendServer) GetPaginationBlacks(ctx context.Context, req *relation.GetPaginationBlacksReq) (resp *relation.GetPaginationBlacksResp, err error) {
 | 
			
		||||
	if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@ -33,7 +34,7 @@ func (s *friendServer) GetPaginationBlacks(ctx context.Context, req *pbfriend.Ge
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	resp = &pbfriend.GetPaginationBlacksResp{}
 | 
			
		||||
	resp = &relation.GetPaginationBlacksResp{}
 | 
			
		||||
	resp.Blacks, err = convert.BlackDB2Pb(ctx, blacks, s.userRpcClient.GetUsersInfoMap)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
@ -42,18 +43,18 @@ func (s *friendServer) GetPaginationBlacks(ctx context.Context, req *pbfriend.Ge
 | 
			
		||||
	return resp, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) IsBlack(ctx context.Context, req *pbfriend.IsBlackReq) (*pbfriend.IsBlackResp, error) {
 | 
			
		||||
func (s *friendServer) IsBlack(ctx context.Context, req *relation.IsBlackReq) (*relation.IsBlackResp, error) {
 | 
			
		||||
	in1, in2, err := s.blackDatabase.CheckIn(ctx, req.UserID1, req.UserID2)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	resp := &pbfriend.IsBlackResp{}
 | 
			
		||||
	resp := &relation.IsBlackResp{}
 | 
			
		||||
	resp.InUser1Blacks = in1
 | 
			
		||||
	resp.InUser2Blacks = in2
 | 
			
		||||
	return resp, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) RemoveBlack(ctx context.Context, req *pbfriend.RemoveBlackReq) (*pbfriend.RemoveBlackResp, error) {
 | 
			
		||||
func (s *friendServer) RemoveBlack(ctx context.Context, req *relation.RemoveBlackReq) (*relation.RemoveBlackResp, error) {
 | 
			
		||||
	if err := s.userRpcClient.Access(ctx, req.OwnerUserID); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@ -64,10 +65,10 @@ func (s *friendServer) RemoveBlack(ctx context.Context, req *pbfriend.RemoveBlac
 | 
			
		||||
 | 
			
		||||
	s.notificationSender.BlackDeletedNotification(ctx, req)
 | 
			
		||||
 | 
			
		||||
	return &pbfriend.RemoveBlackResp{}, nil
 | 
			
		||||
	return &relation.RemoveBlackResp{}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) AddBlack(ctx context.Context, req *pbfriend.AddBlackReq) (*pbfriend.AddBlackResp, error) {
 | 
			
		||||
func (s *friendServer) AddBlack(ctx context.Context, req *relation.AddBlackReq) (*relation.AddBlackResp, error) {
 | 
			
		||||
	if err := authverify.CheckAccessV3(ctx, req.OwnerUserID, s.config.Share.IMAdminUserID); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@ -87,5 +88,5 @@ func (s *friendServer) AddBlack(ctx context.Context, req *pbfriend.AddBlackReq)
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	s.notificationSender.BlackAddedNotification(ctx, req)
 | 
			
		||||
	return &pbfriend.AddBlackResp{}, nil
 | 
			
		||||
	return &relation.AddBlackResp{}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -16,14 +16,15 @@ package friend
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/common/webhook"
 | 
			
		||||
 | 
			
		||||
	cbapi "github.com/openimsdk/open-im-server/v3/pkg/callbackstruct"
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/common/config"
 | 
			
		||||
	pbfriend "github.com/openimsdk/protocol/friend"
 | 
			
		||||
	"github.com/openimsdk/protocol/relation"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) webhookAfterDeleteFriend(ctx context.Context, after *config.AfterConfig, req *pbfriend.DeleteFriendReq) {
 | 
			
		||||
func (s *friendServer) webhookAfterDeleteFriend(ctx context.Context, after *config.AfterConfig, req *relation.DeleteFriendReq) {
 | 
			
		||||
	cbReq := &cbapi.CallbackAfterDeleteFriendReq{
 | 
			
		||||
		CallbackCommand: cbapi.CallbackAfterDeleteFriendCommand,
 | 
			
		||||
		OwnerUserID:     req.OwnerUserID,
 | 
			
		||||
@ -32,7 +33,7 @@ func (s *friendServer) webhookAfterDeleteFriend(ctx context.Context, after *conf
 | 
			
		||||
	s.webhookClient.AsyncPost(ctx, cbReq.GetCallbackCommand(), cbReq, &cbapi.CallbackAfterDeleteFriendResp{}, after)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) webhookBeforeAddFriend(ctx context.Context, before *config.BeforeConfig, req *pbfriend.ApplyToAddFriendReq) error {
 | 
			
		||||
func (s *friendServer) webhookBeforeAddFriend(ctx context.Context, before *config.BeforeConfig, req *relation.ApplyToAddFriendReq) error {
 | 
			
		||||
	return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
 | 
			
		||||
		cbReq := &cbapi.CallbackBeforeAddFriendReq{
 | 
			
		||||
			CallbackCommand: cbapi.CallbackBeforeAddFriendCommand,
 | 
			
		||||
@ -50,7 +51,7 @@ func (s *friendServer) webhookBeforeAddFriend(ctx context.Context, before *confi
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) webhookAfterAddFriend(ctx context.Context, after *config.AfterConfig, req *pbfriend.ApplyToAddFriendReq) {
 | 
			
		||||
func (s *friendServer) webhookAfterAddFriend(ctx context.Context, after *config.AfterConfig, req *relation.ApplyToAddFriendReq) {
 | 
			
		||||
	cbReq := &cbapi.CallbackAfterAddFriendReq{
 | 
			
		||||
		CallbackCommand: cbapi.CallbackAfterAddFriendCommand,
 | 
			
		||||
		FromUserID:      req.FromUserID,
 | 
			
		||||
@ -61,8 +62,7 @@ func (s *friendServer) webhookAfterAddFriend(ctx context.Context, after *config.
 | 
			
		||||
	s.webhookClient.AsyncPost(ctx, cbReq.GetCallbackCommand(), cbReq, resp, after)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) webhookAfterSetFriendRemark(ctx context.Context, after *config.AfterConfig, req *pbfriend.SetFriendRemarkReq) {
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) webhookAfterSetFriendRemark(ctx context.Context, after *config.AfterConfig, req *relation.SetFriendRemarkReq) {
 | 
			
		||||
	cbReq := &cbapi.CallbackAfterSetFriendRemarkReq{
 | 
			
		||||
		CallbackCommand: cbapi.CallbackAfterSetFriendRemarkCommand,
 | 
			
		||||
		OwnerUserID:     req.OwnerUserID,
 | 
			
		||||
@ -73,7 +73,7 @@ func (s *friendServer) webhookAfterSetFriendRemark(ctx context.Context, after *c
 | 
			
		||||
	s.webhookClient.AsyncPost(ctx, cbReq.GetCallbackCommand(), cbReq, resp, after)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) webhookAfterImportFriends(ctx context.Context, after *config.AfterConfig, req *pbfriend.ImportFriendReq) {
 | 
			
		||||
func (s *friendServer) webhookAfterImportFriends(ctx context.Context, after *config.AfterConfig, req *relation.ImportFriendReq) {
 | 
			
		||||
	cbReq := &cbapi.CallbackAfterImportFriendsReq{
 | 
			
		||||
		CallbackCommand: cbapi.CallbackAfterImportFriendsCommand,
 | 
			
		||||
		OwnerUserID:     req.OwnerUserID,
 | 
			
		||||
@ -83,7 +83,7 @@ func (s *friendServer) webhookAfterImportFriends(ctx context.Context, after *con
 | 
			
		||||
	s.webhookClient.AsyncPost(ctx, cbReq.GetCallbackCommand(), cbReq, resp, after)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) webhookAfterRemoveBlack(ctx context.Context, after *config.AfterConfig, req *pbfriend.RemoveBlackReq) {
 | 
			
		||||
func (s *friendServer) webhookAfterRemoveBlack(ctx context.Context, after *config.AfterConfig, req *relation.RemoveBlackReq) {
 | 
			
		||||
	cbReq := &cbapi.CallbackAfterRemoveBlackReq{
 | 
			
		||||
		CallbackCommand: cbapi.CallbackAfterRemoveBlackCommand,
 | 
			
		||||
		OwnerUserID:     req.OwnerUserID,
 | 
			
		||||
@ -93,7 +93,7 @@ func (s *friendServer) webhookAfterRemoveBlack(ctx context.Context, after *confi
 | 
			
		||||
	s.webhookClient.AsyncPost(ctx, cbReq.GetCallbackCommand(), cbReq, resp, after)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) webhookBeforeSetFriendRemark(ctx context.Context, before *config.BeforeConfig, req *pbfriend.SetFriendRemarkReq) error {
 | 
			
		||||
func (s *friendServer) webhookBeforeSetFriendRemark(ctx context.Context, before *config.BeforeConfig, req *relation.SetFriendRemarkReq) error {
 | 
			
		||||
	return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
 | 
			
		||||
		cbReq := &cbapi.CallbackBeforeSetFriendRemarkReq{
 | 
			
		||||
			CallbackCommand: cbapi.CallbackBeforeSetFriendRemarkCommand,
 | 
			
		||||
@ -112,7 +112,7 @@ func (s *friendServer) webhookBeforeSetFriendRemark(ctx context.Context, before
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) webhookBeforeAddBlack(ctx context.Context, before *config.BeforeConfig, req *pbfriend.AddBlackReq) error {
 | 
			
		||||
func (s *friendServer) webhookBeforeAddBlack(ctx context.Context, before *config.BeforeConfig, req *relation.AddBlackReq) error {
 | 
			
		||||
	return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
 | 
			
		||||
		cbReq := &cbapi.CallbackBeforeAddBlackReq{
 | 
			
		||||
			CallbackCommand: cbapi.CallbackBeforeAddBlackCommand,
 | 
			
		||||
@ -124,7 +124,7 @@ func (s *friendServer) webhookBeforeAddBlack(ctx context.Context, before *config
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) webhookBeforeAddFriendAgree(ctx context.Context, before *config.BeforeConfig, req *pbfriend.RespondFriendApplyReq) error {
 | 
			
		||||
func (s *friendServer) webhookBeforeAddFriendAgree(ctx context.Context, before *config.BeforeConfig, req *relation.RespondFriendApplyReq) error {
 | 
			
		||||
	return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
 | 
			
		||||
		cbReq := &cbapi.CallbackBeforeAddFriendAgreeReq{
 | 
			
		||||
			CallbackCommand: cbapi.CallbackBeforeAddFriendAgreeCommand,
 | 
			
		||||
@ -138,7 +138,7 @@ func (s *friendServer) webhookBeforeAddFriendAgree(ctx context.Context, before *
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) webhookBeforeImportFriends(ctx context.Context, before *config.BeforeConfig, req *pbfriend.ImportFriendReq) error {
 | 
			
		||||
func (s *friendServer) webhookBeforeImportFriends(ctx context.Context, before *config.BeforeConfig, req *relation.ImportFriendReq) error {
 | 
			
		||||
	return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
 | 
			
		||||
		cbReq := &cbapi.CallbackBeforeImportFriendsReq{
 | 
			
		||||
			CallbackCommand: cbapi.CallbackBeforeImportFriendsCommand,
 | 
			
		||||
 | 
			
		||||
@ -2,12 +2,12 @@ package friend
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
 | 
			
		||||
	"github.com/openimsdk/protocol/friend"
 | 
			
		||||
	"github.com/openimsdk/protocol/relation"
 | 
			
		||||
	"github.com/openimsdk/tools/utils/datautil"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func friendDB2PB(db *model.Friend) *friend.FriendInfo {
 | 
			
		||||
	return &friend.FriendInfo{
 | 
			
		||||
func friendDB2PB(db *model.Friend) *relation.FriendInfo {
 | 
			
		||||
	return &relation.FriendInfo{
 | 
			
		||||
		OwnerUserID:    db.OwnerUserID,
 | 
			
		||||
		FriendUserID:   db.FriendUserID,
 | 
			
		||||
		FriendNickname: db.FriendNickname,
 | 
			
		||||
@ -21,6 +21,6 @@ func friendDB2PB(db *model.Friend) *friend.FriendInfo {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func friendsDB2PB(db []*model.Friend) []*friend.FriendInfo {
 | 
			
		||||
func friendsDB2PB(db []*model.Friend) []*relation.FriendInfo {
 | 
			
		||||
	return datautil.Slice(db, friendDB2PB)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -16,6 +16,7 @@ package friend
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/common/config"
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
 | 
			
		||||
@ -30,7 +31,7 @@ import (
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/common/storage/controller"
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
 | 
			
		||||
	"github.com/openimsdk/protocol/constant"
 | 
			
		||||
	pbfriend "github.com/openimsdk/protocol/friend"
 | 
			
		||||
	"github.com/openimsdk/protocol/relation"
 | 
			
		||||
	"github.com/openimsdk/protocol/sdkws"
 | 
			
		||||
	"github.com/openimsdk/tools/db/mongoutil"
 | 
			
		||||
	"github.com/openimsdk/tools/discovery"
 | 
			
		||||
@ -54,7 +55,7 @@ type Config struct {
 | 
			
		||||
	RpcConfig     config.Friend
 | 
			
		||||
	RedisConfig   config.Redis
 | 
			
		||||
	MongodbConfig config.Mongo
 | 
			
		||||
	//ZookeeperConfig    config.ZooKeeper
 | 
			
		||||
	// ZookeeperConfig    config.ZooKeeper
 | 
			
		||||
	NotificationConfig config.Notification
 | 
			
		||||
	Share              config.Share
 | 
			
		||||
	WebhooksConfig     config.Webhooks
 | 
			
		||||
@ -103,7 +104,7 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg
 | 
			
		||||
	localcache.InitLocalCache(&config.LocalCacheConfig)
 | 
			
		||||
 | 
			
		||||
	// Register Friend server with refactored MongoDB and Redis integrations
 | 
			
		||||
	pbfriend.RegisterFriendServer(server, &friendServer{
 | 
			
		||||
	relation.RegisterFriendServer(server, &friendServer{
 | 
			
		||||
		friendDatabase: controller.NewFriendDatabase(
 | 
			
		||||
			friendMongoDB,
 | 
			
		||||
			friendRequestMongoDB,
 | 
			
		||||
@ -126,8 +127,8 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ok.
 | 
			
		||||
func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) (resp *pbfriend.ApplyToAddFriendResp, err error) {
 | 
			
		||||
	resp = &pbfriend.ApplyToAddFriendResp{}
 | 
			
		||||
func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *relation.ApplyToAddFriendReq) (resp *relation.ApplyToAddFriendResp, err error) {
 | 
			
		||||
	resp = &relation.ApplyToAddFriendResp{}
 | 
			
		||||
	if err := authverify.CheckAccessV3(ctx, req.FromUserID, s.config.Share.IMAdminUserID); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@ -157,7 +158,7 @@ func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.Apply
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ok.
 | 
			
		||||
func (s *friendServer) ImportFriends(ctx context.Context, req *pbfriend.ImportFriendReq) (resp *pbfriend.ImportFriendResp, err error) {
 | 
			
		||||
func (s *friendServer) ImportFriends(ctx context.Context, req *relation.ImportFriendReq) (resp *relation.ImportFriendResp, err error) {
 | 
			
		||||
	if err := authverify.CheckAdmin(ctx, s.config.Share.IMAdminUserID); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@ -179,7 +180,7 @@ func (s *friendServer) ImportFriends(ctx context.Context, req *pbfriend.ImportFr
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	for _, userID := range req.FriendUserIDs {
 | 
			
		||||
		s.notificationSender.FriendApplicationAgreedNotification(ctx, &pbfriend.RespondFriendApplyReq{
 | 
			
		||||
		s.notificationSender.FriendApplicationAgreedNotification(ctx, &relation.RespondFriendApplyReq{
 | 
			
		||||
			FromUserID:   req.OwnerUserID,
 | 
			
		||||
			ToUserID:     userID,
 | 
			
		||||
			HandleResult: constant.FriendResponseAgree,
 | 
			
		||||
@ -187,12 +188,12 @@ func (s *friendServer) ImportFriends(ctx context.Context, req *pbfriend.ImportFr
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	s.webhookAfterImportFriends(ctx, &s.config.WebhooksConfig.AfterImportFriends, req)
 | 
			
		||||
	return &pbfriend.ImportFriendResp{}, nil
 | 
			
		||||
	return &relation.ImportFriendResp{}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ok.
 | 
			
		||||
func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbfriend.RespondFriendApplyReq) (resp *pbfriend.RespondFriendApplyResp, err error) {
 | 
			
		||||
	resp = &pbfriend.RespondFriendApplyResp{}
 | 
			
		||||
func (s *friendServer) RespondFriendApply(ctx context.Context, req *relation.RespondFriendApplyReq) (resp *relation.RespondFriendApplyResp, err error) {
 | 
			
		||||
	resp = &relation.RespondFriendApplyResp{}
 | 
			
		||||
	if err := authverify.CheckAccessV3(ctx, req.ToUserID, s.config.Share.IMAdminUserID); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@ -226,8 +227,8 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbfriend.Res
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ok.
 | 
			
		||||
func (s *friendServer) DeleteFriend(ctx context.Context, req *pbfriend.DeleteFriendReq) (resp *pbfriend.DeleteFriendResp, err error) {
 | 
			
		||||
	resp = &pbfriend.DeleteFriendResp{}
 | 
			
		||||
func (s *friendServer) DeleteFriend(ctx context.Context, req *relation.DeleteFriendReq) (resp *relation.DeleteFriendResp, err error) {
 | 
			
		||||
	resp = &relation.DeleteFriendResp{}
 | 
			
		||||
	if err := s.userRpcClient.Access(ctx, req.OwnerUserID); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@ -244,11 +245,11 @@ func (s *friendServer) DeleteFriend(ctx context.Context, req *pbfriend.DeleteFri
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ok.
 | 
			
		||||
func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbfriend.SetFriendRemarkReq) (resp *pbfriend.SetFriendRemarkResp, err error) {
 | 
			
		||||
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 {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	resp = &pbfriend.SetFriendRemarkResp{}
 | 
			
		||||
	resp = &relation.SetFriendRemarkResp{}
 | 
			
		||||
	if err := s.userRpcClient.Access(ctx, req.OwnerUserID); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@ -265,8 +266,8 @@ func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbfriend.SetFri
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ok.
 | 
			
		||||
func (s *friendServer) GetDesignatedFriends(ctx context.Context, req *pbfriend.GetDesignatedFriendsReq) (resp *pbfriend.GetDesignatedFriendsResp, err error) {
 | 
			
		||||
	resp = &pbfriend.GetDesignatedFriendsResp{}
 | 
			
		||||
func (s *friendServer) GetDesignatedFriends(ctx context.Context, req *relation.GetDesignatedFriendsReq) (resp *relation.GetDesignatedFriendsResp, err error) {
 | 
			
		||||
	resp = &relation.GetDesignatedFriendsResp{}
 | 
			
		||||
	if datautil.Duplicate(req.FriendUserIDs) {
 | 
			
		||||
		return nil, errs.ErrArgs.WrapMsg("friend userID repeated")
 | 
			
		||||
	}
 | 
			
		||||
@ -282,12 +283,13 @@ func (s *friendServer) GetDesignatedFriends(ctx context.Context, req *pbfriend.G
 | 
			
		||||
 | 
			
		||||
// Get the list of friend requests sent out proactively.
 | 
			
		||||
func (s *friendServer) GetDesignatedFriendsApply(ctx context.Context,
 | 
			
		||||
	req *pbfriend.GetDesignatedFriendsApplyReq) (resp *pbfriend.GetDesignatedFriendsApplyResp, err error) {
 | 
			
		||||
	req *relation.GetDesignatedFriendsApplyReq,
 | 
			
		||||
) (resp *relation.GetDesignatedFriendsApplyResp, err error) {
 | 
			
		||||
	friendRequests, err := s.friendDatabase.FindBothFriendRequests(ctx, req.FromUserID, req.ToUserID)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	resp = &pbfriend.GetDesignatedFriendsApplyResp{}
 | 
			
		||||
	resp = &relation.GetDesignatedFriendsApplyResp{}
 | 
			
		||||
	resp.FriendRequests, err = convert.FriendRequestDB2Pb(ctx, friendRequests, s.userRpcClient.GetUsersInfoMap)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
@ -296,7 +298,7 @@ func (s *friendServer) GetDesignatedFriendsApply(ctx context.Context,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Get received friend requests (i.e., those initiated by others).
 | 
			
		||||
func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbfriend.GetPaginationFriendsApplyToReq) (resp *pbfriend.GetPaginationFriendsApplyToResp, err error) {
 | 
			
		||||
func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *relation.GetPaginationFriendsApplyToReq) (resp *relation.GetPaginationFriendsApplyToResp, err error) {
 | 
			
		||||
	if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@ -304,7 +306,7 @@ func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbf
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	resp = &pbfriend.GetPaginationFriendsApplyToResp{}
 | 
			
		||||
	resp = &relation.GetPaginationFriendsApplyToResp{}
 | 
			
		||||
	resp.FriendRequests, err = convert.FriendRequestDB2Pb(ctx, friendRequests, s.userRpcClient.GetUsersInfoMap)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
@ -313,8 +315,8 @@ func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbf
 | 
			
		||||
	return resp, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *pbfriend.GetPaginationFriendsApplyFromReq) (resp *pbfriend.GetPaginationFriendsApplyFromResp, err error) {
 | 
			
		||||
	resp = &pbfriend.GetPaginationFriendsApplyFromResp{}
 | 
			
		||||
func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *relation.GetPaginationFriendsApplyFromReq) (resp *relation.GetPaginationFriendsApplyFromResp, err error) {
 | 
			
		||||
	resp = &relation.GetPaginationFriendsApplyFromResp{}
 | 
			
		||||
	if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@ -331,8 +333,8 @@ func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ok.
 | 
			
		||||
func (s *friendServer) IsFriend(ctx context.Context, req *pbfriend.IsFriendReq) (resp *pbfriend.IsFriendResp, err error) {
 | 
			
		||||
	resp = &pbfriend.IsFriendResp{}
 | 
			
		||||
func (s *friendServer) IsFriend(ctx context.Context, req *relation.IsFriendReq) (resp *relation.IsFriendResp, err error) {
 | 
			
		||||
	resp = &relation.IsFriendResp{}
 | 
			
		||||
	resp.InUser1Friends, resp.InUser2Friends, err = s.friendDatabase.CheckIn(ctx, req.UserID1, req.UserID2)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
@ -340,7 +342,7 @@ func (s *friendServer) IsFriend(ctx context.Context, req *pbfriend.IsFriendReq)
 | 
			
		||||
	return resp, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbfriend.GetPaginationFriendsReq) (resp *pbfriend.GetPaginationFriendsResp, err error) {
 | 
			
		||||
func (s *friendServer) GetPaginationFriends(ctx context.Context, req *relation.GetPaginationFriendsReq) (resp *relation.GetPaginationFriendsResp, err error) {
 | 
			
		||||
	if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@ -348,7 +350,7 @@ func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbfriend.G
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	resp = &pbfriend.GetPaginationFriendsResp{}
 | 
			
		||||
	resp = &relation.GetPaginationFriendsResp{}
 | 
			
		||||
	resp.FriendsInfo, err = convert.FriendsDB2Pb(ctx, friends, s.userRpcClient.GetUsersInfoMap)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
@ -357,11 +359,11 @@ func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbfriend.G
 | 
			
		||||
	return resp, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) GetFriendIDs(ctx context.Context, req *pbfriend.GetFriendIDsReq) (resp *pbfriend.GetFriendIDsResp, err error) {
 | 
			
		||||
func (s *friendServer) GetFriendIDs(ctx context.Context, req *relation.GetFriendIDsReq) (resp *relation.GetFriendIDsResp, err error) {
 | 
			
		||||
	if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	resp = &pbfriend.GetFriendIDsResp{}
 | 
			
		||||
	resp = &relation.GetFriendIDsResp{}
 | 
			
		||||
	resp.FriendIDs, err = s.friendDatabase.FindFriendUserIDs(ctx, req.UserID)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
@ -369,7 +371,7 @@ func (s *friendServer) GetFriendIDs(ctx context.Context, req *pbfriend.GetFriend
 | 
			
		||||
	return resp, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) GetSpecifiedFriendsInfo(ctx context.Context, req *pbfriend.GetSpecifiedFriendsInfoReq) (*pbfriend.GetSpecifiedFriendsInfoResp, error) {
 | 
			
		||||
func (s *friendServer) GetSpecifiedFriendsInfo(ctx context.Context, req *relation.GetSpecifiedFriendsInfoReq) (*relation.GetSpecifiedFriendsInfoResp, error) {
 | 
			
		||||
	if len(req.UserIDList) == 0 {
 | 
			
		||||
		return nil, errs.ErrArgs.WrapMsg("userIDList is empty")
 | 
			
		||||
	}
 | 
			
		||||
@ -394,8 +396,8 @@ func (s *friendServer) GetSpecifiedFriendsInfo(ctx context.Context, req *pbfrien
 | 
			
		||||
	blackMap := datautil.SliceToMap(blacks, func(e *model.Black) string {
 | 
			
		||||
		return e.BlockUserID
 | 
			
		||||
	})
 | 
			
		||||
	resp := &pbfriend.GetSpecifiedFriendsInfoResp{
 | 
			
		||||
		Infos: make([]*pbfriend.GetSpecifiedFriendsInfoInfo, 0, len(req.UserIDList)),
 | 
			
		||||
	resp := &relation.GetSpecifiedFriendsInfoResp{
 | 
			
		||||
		Infos: make([]*relation.GetSpecifiedFriendsInfoInfo, 0, len(req.UserIDList)),
 | 
			
		||||
	}
 | 
			
		||||
	for _, userID := range req.UserIDList {
 | 
			
		||||
		user := userMap[userID]
 | 
			
		||||
@ -404,7 +406,6 @@ func (s *friendServer) GetSpecifiedFriendsInfo(ctx context.Context, req *pbfrien
 | 
			
		||||
		}
 | 
			
		||||
		var friendInfo *sdkws.FriendInfo
 | 
			
		||||
		if friend := friendMap[userID]; friend != nil {
 | 
			
		||||
 | 
			
		||||
			friendInfo = &sdkws.FriendInfo{
 | 
			
		||||
				OwnerUserID:    friend.OwnerUserID,
 | 
			
		||||
				Remark:         friend.Remark,
 | 
			
		||||
@ -425,7 +426,7 @@ func (s *friendServer) GetSpecifiedFriendsInfo(ctx context.Context, req *pbfrien
 | 
			
		||||
				Ex:             black.Ex,
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		resp.Infos = append(resp.Infos, &pbfriend.GetSpecifiedFriendsInfoInfo{
 | 
			
		||||
		resp.Infos = append(resp.Infos, &relation.GetSpecifiedFriendsInfoInfo{
 | 
			
		||||
			UserInfo:   user,
 | 
			
		||||
			FriendInfo: friendInfo,
 | 
			
		||||
			BlackInfo:  blackInfo,
 | 
			
		||||
@ -433,10 +434,11 @@ func (s *friendServer) GetSpecifiedFriendsInfo(ctx context.Context, req *pbfrien
 | 
			
		||||
	}
 | 
			
		||||
	return resp, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) UpdateFriends(
 | 
			
		||||
	ctx context.Context,
 | 
			
		||||
	req *pbfriend.UpdateFriendsReq,
 | 
			
		||||
) (*pbfriend.UpdateFriendsResp, error) {
 | 
			
		||||
	req *relation.UpdateFriendsReq,
 | 
			
		||||
) (*relation.UpdateFriendsResp, error) {
 | 
			
		||||
	if len(req.FriendUserIDs) == 0 {
 | 
			
		||||
		return nil, errs.ErrArgs.WrapMsg("friendIDList is empty")
 | 
			
		||||
	}
 | 
			
		||||
@ -464,8 +466,23 @@ func (s *friendServer) UpdateFriends(
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	resp := &pbfriend.UpdateFriendsResp{}
 | 
			
		||||
	resp := &relation.UpdateFriendsResp{}
 | 
			
		||||
 | 
			
		||||
	s.notificationSender.FriendsInfoUpdateNotification(ctx, req.OwnerUserID, req.FriendUserIDs)
 | 
			
		||||
	return resp, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) GetIncrementalFriendsApplyTo(ctx context.Context, req *relation.GetIncrementalFriendsApplyToReq) (*relation.GetIncrementalFriendsApplyToResp, error) {
 | 
			
		||||
	// TODO implement me
 | 
			
		||||
	return nil, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) GetIncrementalFriendsApplyFrom(ctx context.Context, req *relation.GetIncrementalFriendsApplyFromReq) (*relation.GetIncrementalFriendsApplyFromResp, error) {
 | 
			
		||||
	// TODO implement me
 | 
			
		||||
	return nil, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) GetIncrementalBlacks(ctx context.Context, req *relation.GetIncrementalBlacksReq) (*relation.GetIncrementalBlacksResp, error) {
 | 
			
		||||
	// TODO implement me
 | 
			
		||||
	return nil, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -16,6 +16,7 @@ package friend
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
 | 
			
		||||
	relationtb "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
 | 
			
		||||
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/common/config"
 | 
			
		||||
@ -24,7 +25,7 @@ import (
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/rpcclient/notification"
 | 
			
		||||
	"github.com/openimsdk/protocol/constant"
 | 
			
		||||
	pbfriend "github.com/openimsdk/protocol/friend"
 | 
			
		||||
	"github.com/openimsdk/protocol/relation"
 | 
			
		||||
	"github.com/openimsdk/protocol/sdkws"
 | 
			
		||||
	"github.com/openimsdk/tools/mcontext"
 | 
			
		||||
)
 | 
			
		||||
@ -127,7 +128,7 @@ func (f *FriendNotificationSender) UserInfoUpdatedNotification(ctx context.Conte
 | 
			
		||||
	f.Notification(ctx, mcontext.GetOpUserID(ctx), changedUserID, constant.UserInfoUpdatedNotification, &tips)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (f *FriendNotificationSender) FriendApplicationAddNotification(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) {
 | 
			
		||||
func (f *FriendNotificationSender) FriendApplicationAddNotification(ctx context.Context, req *relation.ApplyToAddFriendReq) {
 | 
			
		||||
	tips := sdkws.FriendApplicationTips{FromToUserID: &sdkws.FromToUserID{
 | 
			
		||||
		FromUserID: req.FromUserID,
 | 
			
		||||
		ToUserID:   req.ToUserID,
 | 
			
		||||
@ -137,7 +138,7 @@ func (f *FriendNotificationSender) FriendApplicationAddNotification(ctx context.
 | 
			
		||||
 | 
			
		||||
func (f *FriendNotificationSender) FriendApplicationAgreedNotification(
 | 
			
		||||
	ctx context.Context,
 | 
			
		||||
	req *pbfriend.RespondFriendApplyReq,
 | 
			
		||||
	req *relation.RespondFriendApplyReq,
 | 
			
		||||
) {
 | 
			
		||||
	tips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{
 | 
			
		||||
		FromUserID: req.FromUserID,
 | 
			
		||||
@ -148,7 +149,7 @@ func (f *FriendNotificationSender) FriendApplicationAgreedNotification(
 | 
			
		||||
 | 
			
		||||
func (f *FriendNotificationSender) FriendApplicationRefusedNotification(
 | 
			
		||||
	ctx context.Context,
 | 
			
		||||
	req *pbfriend.RespondFriendApplyReq,
 | 
			
		||||
	req *relation.RespondFriendApplyReq,
 | 
			
		||||
) {
 | 
			
		||||
	tips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{
 | 
			
		||||
		FromUserID: req.FromUserID,
 | 
			
		||||
@ -182,7 +183,7 @@ func (f *FriendNotificationSender) FriendAddedNotification(
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (f *FriendNotificationSender) FriendDeletedNotification(ctx context.Context, req *pbfriend.DeleteFriendReq) {
 | 
			
		||||
func (f *FriendNotificationSender) FriendDeletedNotification(ctx context.Context, req *relation.DeleteFriendReq) {
 | 
			
		||||
	tips := sdkws.FriendDeletedTips{FromToUserID: &sdkws.FromToUserID{
 | 
			
		||||
		FromUserID: req.OwnerUserID,
 | 
			
		||||
		ToUserID:   req.FriendUserID,
 | 
			
		||||
@ -204,14 +205,14 @@ func (f *FriendNotificationSender) FriendsInfoUpdateNotification(ctx context.Con
 | 
			
		||||
	f.Notification(ctx, toUserID, toUserID, constant.FriendsInfoUpdateNotification, &tips)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (f *FriendNotificationSender) BlackAddedNotification(ctx context.Context, req *pbfriend.AddBlackReq) {
 | 
			
		||||
func (f *FriendNotificationSender) BlackAddedNotification(ctx context.Context, req *relation.AddBlackReq) {
 | 
			
		||||
	tips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}}
 | 
			
		||||
	tips.FromToUserID.FromUserID = req.OwnerUserID
 | 
			
		||||
	tips.FromToUserID.ToUserID = req.BlackUserID
 | 
			
		||||
	f.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &tips)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (f *FriendNotificationSender) BlackDeletedNotification(ctx context.Context, req *pbfriend.RemoveBlackReq) {
 | 
			
		||||
func (f *FriendNotificationSender) BlackDeletedNotification(ctx context.Context, req *relation.RemoveBlackReq) {
 | 
			
		||||
	blackDeletedTips := sdkws.BlackDeletedTips{FromToUserID: &sdkws.FromToUserID{
 | 
			
		||||
		FromUserID: req.OwnerUserID,
 | 
			
		||||
		ToUserID:   req.BlackUserID,
 | 
			
		||||
 | 
			
		||||
@ -2,14 +2,15 @@ package friend
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/internal/rpc/incrversion"
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/authverify"
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
 | 
			
		||||
	pbfriend "github.com/openimsdk/protocol/friend"
 | 
			
		||||
	"github.com/openimsdk/protocol/relation"
 | 
			
		||||
	"github.com/openimsdk/tools/errs"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) NotificationUserInfoUpdate(ctx context.Context, req *pbfriend.NotificationUserInfoUpdateReq) (*pbfriend.NotificationUserInfoUpdateResp, error) {
 | 
			
		||||
func (s *friendServer) NotificationUserInfoUpdate(ctx context.Context, req *relation.NotificationUserInfoUpdateReq) (*relation.NotificationUserInfoUpdateResp, error) {
 | 
			
		||||
	if req.NewUserInfo == nil {
 | 
			
		||||
		var err error
 | 
			
		||||
		req.NewUserInfo, err = s.userRpcClient.GetUserInfo(ctx, req.UserID)
 | 
			
		||||
@ -30,10 +31,10 @@ func (s *friendServer) NotificationUserInfoUpdate(ctx context.Context, req *pbfr
 | 
			
		||||
		}
 | 
			
		||||
		s.notificationSender.FriendsInfoUpdateNotification(ctx, req.UserID, userIDs)
 | 
			
		||||
	}
 | 
			
		||||
	return &pbfriend.NotificationUserInfoUpdateResp{}, nil
 | 
			
		||||
	return &relation.NotificationUserInfoUpdateResp{}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) SearchFriends(ctx context.Context, req *pbfriend.SearchFriendsReq) (*pbfriend.SearchFriendsResp, error) {
 | 
			
		||||
func (s *friendServer) SearchFriends(ctx context.Context, req *relation.SearchFriendsReq) (*relation.SearchFriendsResp, error) {
 | 
			
		||||
	if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@ -42,7 +43,7 @@ func (s *friendServer) SearchFriends(ctx context.Context, req *pbfriend.SearchFr
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
		return &pbfriend.SearchFriendsResp{
 | 
			
		||||
		return &relation.SearchFriendsResp{
 | 
			
		||||
			Total:   total,
 | 
			
		||||
			Friends: friendsDB2PB(friends),
 | 
			
		||||
		}, nil
 | 
			
		||||
@ -51,17 +52,17 @@ func (s *friendServer) SearchFriends(ctx context.Context, req *pbfriend.SearchFr
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	return &pbfriend.SearchFriendsResp{
 | 
			
		||||
	return &relation.SearchFriendsResp{
 | 
			
		||||
		Total:   total,
 | 
			
		||||
		Friends: friendsDB2PB(friends),
 | 
			
		||||
	}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *friendServer) GetIncrementalFriends(ctx context.Context, req *pbfriend.GetIncrementalFriendsReq) (*pbfriend.GetIncrementalFriendsResp, error) {
 | 
			
		||||
func (s *friendServer) GetIncrementalFriends(ctx context.Context, req *relation.GetIncrementalFriendsReq) (*relation.GetIncrementalFriendsResp, error) {
 | 
			
		||||
	if err := authverify.CheckAccessV3(ctx, req.UserID, s.config.Share.IMAdminUserID); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	opt := incrversion.Option[*pbfriend.FriendInfo, pbfriend.GetIncrementalFriendsResp]{
 | 
			
		||||
	opt := incrversion.Option[*relation.FriendInfo, relation.GetIncrementalFriendsResp]{
 | 
			
		||||
		VersionID: req.VersionID,
 | 
			
		||||
		Version: func() (*model.VersionLog, error) {
 | 
			
		||||
			return s.friendDatabase.FindFriendIncrVersion(ctx, req.UserID, uint(req.Version), incrversion.Limit(s.config.RpcConfig.FriendSyncCount, req.Version))
 | 
			
		||||
@ -69,18 +70,18 @@ func (s *friendServer) GetIncrementalFriends(ctx context.Context, req *pbfriend.
 | 
			
		||||
		AllID: func() ([]string, error) {
 | 
			
		||||
			return s.friendDatabase.FindSortFriendUserIDs(ctx, req.UserID)
 | 
			
		||||
		},
 | 
			
		||||
		Find: func(ids []string) ([]*pbfriend.FriendInfo, error) {
 | 
			
		||||
		Find: func(ids []string) ([]*relation.FriendInfo, error) {
 | 
			
		||||
			friends, err := s.friendDatabase.FindFriendsWithError(ctx, req.UserID, ids)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return nil, err
 | 
			
		||||
			}
 | 
			
		||||
			return friendsDB2PB(friends), nil
 | 
			
		||||
		},
 | 
			
		||||
		ID: func(elem *pbfriend.FriendInfo) string {
 | 
			
		||||
		ID: func(elem *relation.FriendInfo) string {
 | 
			
		||||
			return elem.FriendUserID
 | 
			
		||||
		},
 | 
			
		||||
		Resp: func(version *model.VersionLog, delIDs []string, list []*pbfriend.FriendInfo, full bool) *pbfriend.GetIncrementalFriendsResp {
 | 
			
		||||
			return &pbfriend.GetIncrementalFriendsResp{
 | 
			
		||||
		Resp: func(version *model.VersionLog, delIDs []string, list []*relation.FriendInfo, full bool) *relation.GetIncrementalFriendsResp {
 | 
			
		||||
			return &relation.GetIncrementalFriendsResp{
 | 
			
		||||
				VersionID:     version.ID.Hex(),
 | 
			
		||||
				Version:       uint64(version.Version),
 | 
			
		||||
				Full:          full,
 | 
			
		||||
@ -93,7 +94,7 @@ func (s *friendServer) GetIncrementalFriends(ctx context.Context, req *pbfriend.
 | 
			
		||||
	return opt.Build()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//func (s *friendServer) GetIncrementalFriends(ctx context.Context, req *pbfriend.GetIncrementalFriendsReq) (*pbfriend.GetIncrementalFriendsResp, error) {
 | 
			
		||||
//func (s *friendServer) GetIncrementalFriends(ctx context.Context, req *relation.GetIncrementalFriendsReq) (*relation.GetIncrementalFriendsResp, error) {
 | 
			
		||||
//	if err := authverify.CheckAccessV3(ctx, req.UserID, s.config.Share.IMAdminUserID); err != nil {
 | 
			
		||||
//		return nil, err
 | 
			
		||||
//	}
 | 
			
		||||
@ -124,7 +125,7 @@ func (s *friendServer) GetIncrementalFriends(ctx context.Context, req *pbfriend.
 | 
			
		||||
//			return nil, err
 | 
			
		||||
//		}
 | 
			
		||||
//	}
 | 
			
		||||
//	return &pbfriend.GetIncrementalFriendsResp{
 | 
			
		||||
//	return &relation.GetIncrementalFriendsResp{
 | 
			
		||||
//		Version:       uint64(incrVer.Version),
 | 
			
		||||
//		VersionID:     incrVer.ID.Hex(),
 | 
			
		||||
//		Full:          incrVer.Full(),
 | 
			
		||||
 | 
			
		||||
@ -17,6 +17,11 @@ package user
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"math/rand"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"sync"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/internal/rpc/friend"
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/common/config"
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
 | 
			
		||||
@ -24,13 +29,9 @@ import (
 | 
			
		||||
	tablerelation "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/common/webhook"
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/localcache"
 | 
			
		||||
	friendpb "github.com/openimsdk/protocol/friend"
 | 
			
		||||
	"github.com/openimsdk/protocol/group"
 | 
			
		||||
	"github.com/openimsdk/protocol/relation"
 | 
			
		||||
	"github.com/openimsdk/tools/db/redisutil"
 | 
			
		||||
	"math/rand"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"sync"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/authverify"
 | 
			
		||||
	"github.com/openimsdk/open-im-server/v3/pkg/common/convert"
 | 
			
		||||
@ -123,8 +124,7 @@ func (s *userServer) GetDesignateUsers(ctx context.Context, req *pbuser.GetDesig
 | 
			
		||||
 | 
			
		||||
// deprecated:
 | 
			
		||||
 | 
			
		||||
//UpdateUserInfo
 | 
			
		||||
 | 
			
		||||
// UpdateUserInfo
 | 
			
		||||
func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserInfoReq) (resp *pbuser.UpdateUserInfoResp, err error) {
 | 
			
		||||
	resp = &pbuser.UpdateUserInfoResp{}
 | 
			
		||||
	err = authverify.CheckAccessV3(ctx, req.UserInfo.UserID, s.config.Share.IMAdminUserID)
 | 
			
		||||
@ -162,6 +162,7 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserI
 | 
			
		||||
	}
 | 
			
		||||
	return resp, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *userServer) UpdateUserInfoEx(ctx context.Context, req *pbuser.UpdateUserInfoExReq) (resp *pbuser.UpdateUserInfoExResp, err error) {
 | 
			
		||||
	resp = &pbuser.UpdateUserInfoExResp{}
 | 
			
		||||
	err = authverify.CheckAccessV3(ctx, req.UserInfo.UserID, s.config.Share.IMAdminUserID)
 | 
			
		||||
@ -198,6 +199,7 @@ func (s *userServer) UpdateUserInfoEx(ctx context.Context, req *pbuser.UpdateUse
 | 
			
		||||
	}
 | 
			
		||||
	return resp, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *userServer) SetGlobalRecvMessageOpt(ctx context.Context, req *pbuser.SetGlobalRecvMessageOptReq) (resp *pbuser.SetGlobalRecvMessageOptResp, err error) {
 | 
			
		||||
	resp = &pbuser.SetGlobalRecvMessageOptResp{}
 | 
			
		||||
	if _, err := s.db.FindWithError(ctx, []string{req.UserID}); err != nil {
 | 
			
		||||
@ -256,7 +258,6 @@ func (s *userServer) GetPaginationUsers(ctx context.Context, req *pbuser.GetPagi
 | 
			
		||||
		return &pbuser.GetPaginationUsersResp{Total: int32(total), Users: convert.UsersDB2Pb(users)}, err
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *userServer) UserRegister(ctx context.Context, req *pbuser.UserRegisterReq) (resp *pbuser.UserRegisterResp, err error) {
 | 
			
		||||
@ -353,7 +354,8 @@ func (s *userServer) SubscribeOrCancelUsersStatus(ctx context.Context, req *pbus
 | 
			
		||||
 | 
			
		||||
// GetUserStatus Get the online status of the user.
 | 
			
		||||
func (s *userServer) GetUserStatus(ctx context.Context, req *pbuser.GetUserStatusReq) (resp *pbuser.GetUserStatusResp,
 | 
			
		||||
	err error) {
 | 
			
		||||
	err error,
 | 
			
		||||
) {
 | 
			
		||||
	onlineStatusList, err := s.db.GetUserStatus(ctx, req.UserIDs)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
@ -363,7 +365,8 @@ func (s *userServer) GetUserStatus(ctx context.Context, req *pbuser.GetUserStatu
 | 
			
		||||
 | 
			
		||||
// SetUserStatus Synchronize user's online status.
 | 
			
		||||
func (s *userServer) SetUserStatus(ctx context.Context, req *pbuser.SetUserStatusReq) (resp *pbuser.SetUserStatusResp,
 | 
			
		||||
	err error) {
 | 
			
		||||
	err error,
 | 
			
		||||
) {
 | 
			
		||||
	err = s.db.SetUserStatus(ctx, req.UserID, req.Status, req.PlatformID)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
@ -387,7 +390,8 @@ func (s *userServer) SetUserStatus(ctx context.Context, req *pbuser.SetUserStatu
 | 
			
		||||
 | 
			
		||||
// GetSubscribeUsersStatus Get the online status of subscribers.
 | 
			
		||||
func (s *userServer) GetSubscribeUsersStatus(ctx context.Context,
 | 
			
		||||
	req *pbuser.GetSubscribeUsersStatusReq) (*pbuser.GetSubscribeUsersStatusResp, error) {
 | 
			
		||||
	req *pbuser.GetSubscribeUsersStatusReq,
 | 
			
		||||
) (*pbuser.GetSubscribeUsersStatusResp, error) {
 | 
			
		||||
	userList, err := s.db.GetAllSubscribeList(ctx, req.UserID)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
@ -476,7 +480,6 @@ func (s *userServer) ProcessUserCommandUpdate(ctx context.Context, req *pbuser.P
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *userServer) ProcessUserCommandGet(ctx context.Context, req *pbuser.ProcessUserCommandGetReq) (*pbuser.ProcessUserCommandGetResp, error) {
 | 
			
		||||
 | 
			
		||||
	err := authverify.CheckAccessV3(ctx, req.UserID, s.config.Share.IMAdminUserID)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
@ -723,7 +726,7 @@ func (s *userServer) NotificationUserInfoUpdate(ctx context.Context, userID stri
 | 
			
		||||
 | 
			
		||||
	go func() {
 | 
			
		||||
		defer wg.Done()
 | 
			
		||||
		_, es[1] = s.friendRpcClient.Client.NotificationUserInfoUpdate(ctx, &friendpb.NotificationUserInfoUpdateReq{
 | 
			
		||||
		_, es[1] = s.friendRpcClient.Client.NotificationUserInfoUpdate(ctx, &relation.NotificationUserInfoUpdateReq{
 | 
			
		||||
			UserID:      userID,
 | 
			
		||||
			OldUserInfo: oldUserInfo,
 | 
			
		||||
			NewUserInfo: newUserInfo,
 | 
			
		||||
 | 
			
		||||
@ -17,7 +17,7 @@ package rpcclient
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
 | 
			
		||||
	"github.com/openimsdk/protocol/friend"
 | 
			
		||||
	"github.com/openimsdk/protocol/relation"
 | 
			
		||||
	sdkws "github.com/openimsdk/protocol/sdkws"
 | 
			
		||||
	"github.com/openimsdk/tools/discovery"
 | 
			
		||||
	"github.com/openimsdk/tools/system/program"
 | 
			
		||||
@ -26,7 +26,7 @@ import (
 | 
			
		||||
 | 
			
		||||
type Friend struct {
 | 
			
		||||
	conn   grpc.ClientConnInterface
 | 
			
		||||
	Client friend.FriendClient
 | 
			
		||||
	Client relation.FriendClient
 | 
			
		||||
	discov discovery.SvcDiscoveryRegistry
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -35,7 +35,7 @@ func NewFriend(discov discovery.SvcDiscoveryRegistry, rpcRegisterName string) *F
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		program.ExitWithError(err)
 | 
			
		||||
	}
 | 
			
		||||
	client := friend.NewFriendClient(conn)
 | 
			
		||||
	client := relation.NewFriendClient(conn)
 | 
			
		||||
	return &Friend{discov: discov, conn: conn, Client: client}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -47,11 +47,11 @@ func NewFriendRpcClient(discov discovery.SvcDiscoveryRegistry, rpcRegisterName s
 | 
			
		||||
 | 
			
		||||
func (f *FriendRpcClient) GetFriendsInfo(
 | 
			
		||||
	ctx context.Context,
 | 
			
		||||
	ownerUserID, friendUserID string,
 | 
			
		||||
	ownerUserID, relationUserID string,
 | 
			
		||||
) (resp *sdkws.FriendInfo, err error) {
 | 
			
		||||
	r, err := f.Client.GetDesignatedFriends(
 | 
			
		||||
		ctx,
 | 
			
		||||
		&friend.GetDesignatedFriendsReq{OwnerUserID: ownerUserID, FriendUserIDs: []string{friendUserID}},
 | 
			
		||||
		&relation.GetDesignatedFriendsReq{OwnerUserID: ownerUserID, FriendUserIDs: []string{relationUserID}},
 | 
			
		||||
	)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
@ -60,17 +60,17 @@ func (f *FriendRpcClient) GetFriendsInfo(
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// possibleFriendUserID Is PossibleFriendUserId's friends.
 | 
			
		||||
// possibleFriendUserID Is PossibleFriendUserId's relations.
 | 
			
		||||
func (f *FriendRpcClient) IsFriend(ctx context.Context, possibleFriendUserID, userID string) (bool, error) {
 | 
			
		||||
	resp, err := f.Client.IsFriend(ctx, &friend.IsFriendReq{UserID1: userID, UserID2: possibleFriendUserID})
 | 
			
		||||
	resp, err := f.Client.IsFriend(ctx, &relation.IsFriendReq{UserID1: userID, UserID2: possibleFriendUserID})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return false, err
 | 
			
		||||
	}
 | 
			
		||||
	return resp.InUser1Friends, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (f *FriendRpcClient) GetFriendIDs(ctx context.Context, ownerUserID string) (friendIDs []string, err error) {
 | 
			
		||||
	req := friend.GetFriendIDsReq{UserID: ownerUserID}
 | 
			
		||||
func (f *FriendRpcClient) GetFriendIDs(ctx context.Context, ownerUserID string) (relationIDs []string, err error) {
 | 
			
		||||
	req := relation.GetFriendIDsReq{UserID: ownerUserID}
 | 
			
		||||
	resp, err := f.Client.GetFriendIDs(ctx, &req)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
@ -79,7 +79,7 @@ func (f *FriendRpcClient) GetFriendIDs(ctx context.Context, ownerUserID string)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b *FriendRpcClient) IsBlack(ctx context.Context, possibleBlackUserID, userID string) (bool, error) {
 | 
			
		||||
	r, err := b.Client.IsBlack(ctx, &friend.IsBlackReq{UserID1: possibleBlackUserID, UserID2: userID})
 | 
			
		||||
	r, err := b.Client.IsBlack(ctx, &relation.IsBlackReq{UserID1: possibleBlackUserID, UserID2: userID})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return false, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user