mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-15 22:39:03 +08:00
Merge branch 'main' into localcache
# Conflicts: # go.mod # go.sum # internal/msggateway/hub_server.go # internal/push/consumer_init.go # internal/push/offlinepush/fcm/push.go # internal/push/offlinepush/getui/push.go # internal/push/offlinepush/jpush/push.go # internal/push/push_handler.go # internal/push/push_rpc_server.go # internal/push/push_to_client.go # internal/rpc/friend/friend.go # internal/rpc/msg/server.go # internal/rpc/msg/verify.go # pkg/common/config/config.go # pkg/common/db/cache/conversation.go # pkg/common/db/cache/meta_cache.go # pkg/common/db/cache/msg.go # pkg/common/db/localcache/conversation.go # pkg/common/db/localcache/group.go # pkg/rpcclient/conversation.go # pkg/rpcclient/group.go
This commit is contained in:
@@ -18,11 +18,9 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
||||
|
||||
pbfriend "github.com/OpenIMSDK/protocol/friend"
|
||||
"github.com/OpenIMSDK/tools/mcontext"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/convert"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"
|
||||
)
|
||||
@@ -67,7 +65,7 @@ func (s *friendServer) RemoveBlack(ctx context.Context, req *pbfriend.RemoveBlac
|
||||
}
|
||||
|
||||
func (s *friendServer) AddBlack(ctx context.Context, req *pbfriend.AddBlackReq) (*pbfriend.AddBlackResp, error) {
|
||||
if err := authverify.CheckAccessV3(ctx, req.OwnerUserID); err != nil {
|
||||
if err := authverify.CheckAccessV3(ctx, req.OwnerUserID, s.config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err := s.userRpcClient.GetUsersInfo(ctx, []string{req.OwnerUserID, req.BlackUserID})
|
||||
|
||||
@@ -19,14 +19,13 @@ import (
|
||||
|
||||
pbfriend "github.com/OpenIMSDK/protocol/friend"
|
||||
"github.com/OpenIMSDK/tools/utils"
|
||||
|
||||
cbapi "github.com/openimsdk/open-im-server/v3/pkg/callbackstruct"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/http"
|
||||
)
|
||||
|
||||
func CallbackBeforeAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) error {
|
||||
if !config.Config.Callback.CallbackBeforeAddFriend.Enable {
|
||||
func CallbackBeforeAddFriend(ctx context.Context, globalConfig *config.GlobalConfig, req *pbfriend.ApplyToAddFriendReq) error {
|
||||
if !globalConfig.Callback.CallbackBeforeAddFriend.Enable {
|
||||
return nil
|
||||
}
|
||||
cbReq := &cbapi.CallbackBeforeAddFriendReq{
|
||||
@@ -37,14 +36,14 @@ func CallbackBeforeAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriend
|
||||
Ex: req.Ex,
|
||||
}
|
||||
resp := &cbapi.CallbackBeforeAddFriendResp{}
|
||||
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeAddFriend); err != nil {
|
||||
if err := http.CallBackPostReturn(ctx, globalConfig.Callback.CallbackUrl, cbReq, resp, globalConfig.Callback.CallbackBeforeAddFriend); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CallbackBeforeSetFriendRemark(ctx context.Context, req *pbfriend.SetFriendRemarkReq) error {
|
||||
if !config.Config.Callback.CallbackBeforeSetFriendRemark.Enable {
|
||||
func CallbackBeforeSetFriendRemark(ctx context.Context, globalConfig *config.GlobalConfig, req *pbfriend.SetFriendRemarkReq) error {
|
||||
if !globalConfig.Callback.CallbackBeforeSetFriendRemark.Enable {
|
||||
return nil
|
||||
}
|
||||
cbReq := &cbapi.CallbackBeforeSetFriendRemarkReq{
|
||||
@@ -54,15 +53,15 @@ func CallbackBeforeSetFriendRemark(ctx context.Context, req *pbfriend.SetFriendR
|
||||
Remark: req.Remark,
|
||||
}
|
||||
resp := &cbapi.CallbackBeforeSetFriendRemarkResp{}
|
||||
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeAddFriend); err != nil {
|
||||
if err := http.CallBackPostReturn(ctx, globalConfig.Callback.CallbackUrl, cbReq, resp, globalConfig.Callback.CallbackBeforeAddFriend); err != nil {
|
||||
return err
|
||||
}
|
||||
utils.NotNilReplace(&req.Remark, &resp.Remark)
|
||||
return nil
|
||||
}
|
||||
|
||||
func CallbackAfterSetFriendRemark(ctx context.Context, req *pbfriend.SetFriendRemarkReq) error {
|
||||
if !config.Config.Callback.CallbackAfterSetFriendRemark.Enable {
|
||||
func CallbackAfterSetFriendRemark(ctx context.Context, globalConfig *config.GlobalConfig, req *pbfriend.SetFriendRemarkReq) error {
|
||||
if !globalConfig.Callback.CallbackAfterSetFriendRemark.Enable {
|
||||
return nil
|
||||
}
|
||||
cbReq := &cbapi.CallbackAfterSetFriendRemarkReq{
|
||||
@@ -72,13 +71,13 @@ func CallbackAfterSetFriendRemark(ctx context.Context, req *pbfriend.SetFriendRe
|
||||
Remark: req.Remark,
|
||||
}
|
||||
resp := &cbapi.CallbackAfterSetFriendRemarkResp{}
|
||||
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeAddFriend); err != nil {
|
||||
if err := http.CallBackPostReturn(ctx, globalConfig.Callback.CallbackUrl, cbReq, resp, globalConfig.Callback.CallbackBeforeAddFriend); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func CallbackBeforeAddBlack(ctx context.Context, req *pbfriend.AddBlackReq) error {
|
||||
if !config.Config.Callback.CallbackBeforeAddBlack.Enable {
|
||||
func CallbackBeforeAddBlack(ctx context.Context, globalConfig *config.GlobalConfig, req *pbfriend.AddBlackReq) error {
|
||||
if !globalConfig.Callback.CallbackBeforeAddBlack.Enable {
|
||||
return nil
|
||||
}
|
||||
cbReq := &cbapi.CallbackBeforeAddBlackReq{
|
||||
@@ -87,13 +86,13 @@ func CallbackBeforeAddBlack(ctx context.Context, req *pbfriend.AddBlackReq) erro
|
||||
BlackUserID: req.BlackUserID,
|
||||
}
|
||||
resp := &cbapi.CallbackBeforeAddBlackResp{}
|
||||
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeAddBlack); err != nil {
|
||||
if err := http.CallBackPostReturn(ctx, globalConfig.Callback.CallbackUrl, cbReq, resp, globalConfig.Callback.CallbackBeforeAddBlack); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func CallbackAfterAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) error {
|
||||
if !config.Config.Callback.CallbackAfterAddFriend.Enable {
|
||||
func CallbackAfterAddFriend(ctx context.Context, globalConfig *config.GlobalConfig, req *pbfriend.ApplyToAddFriendReq) error {
|
||||
if !globalConfig.Callback.CallbackAfterAddFriend.Enable {
|
||||
return nil
|
||||
}
|
||||
cbReq := &cbapi.CallbackAfterAddFriendReq{
|
||||
@@ -103,14 +102,14 @@ func CallbackAfterAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendR
|
||||
ReqMsg: req.ReqMsg,
|
||||
}
|
||||
resp := &cbapi.CallbackAfterAddFriendResp{}
|
||||
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackAfterAddFriend); err != nil {
|
||||
if err := http.CallBackPostReturn(ctx, globalConfig.Callback.CallbackUrl, cbReq, resp, globalConfig.Callback.CallbackAfterAddFriend); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
func CallbackBeforeAddFriendAgree(ctx context.Context, req *pbfriend.RespondFriendApplyReq) error {
|
||||
if !config.Config.Callback.CallbackBeforeAddFriendAgree.Enable {
|
||||
func CallbackBeforeAddFriendAgree(ctx context.Context, globalConfig *config.GlobalConfig, req *pbfriend.RespondFriendApplyReq) error {
|
||||
if !globalConfig.Callback.CallbackBeforeAddFriendAgree.Enable {
|
||||
return nil
|
||||
}
|
||||
cbReq := &cbapi.CallbackBeforeAddFriendAgreeReq{
|
||||
@@ -121,13 +120,13 @@ func CallbackBeforeAddFriendAgree(ctx context.Context, req *pbfriend.RespondFrie
|
||||
HandleResult: req.HandleResult,
|
||||
}
|
||||
resp := &cbapi.CallbackBeforeAddFriendAgreeResp{}
|
||||
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeAddFriendAgree); err != nil {
|
||||
if err := http.CallBackPostReturn(ctx, globalConfig.Callback.CallbackUrl, cbReq, resp, globalConfig.Callback.CallbackBeforeAddFriendAgree); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func CallbackAfterDeleteFriend(ctx context.Context, req *pbfriend.DeleteFriendReq) error {
|
||||
if !config.Config.Callback.CallbackAfterDeleteFriend.Enable {
|
||||
func CallbackAfterDeleteFriend(ctx context.Context, globalConfig *config.GlobalConfig, req *pbfriend.DeleteFriendReq) error {
|
||||
if !globalConfig.Callback.CallbackAfterDeleteFriend.Enable {
|
||||
return nil
|
||||
}
|
||||
cbReq := &cbapi.CallbackAfterDeleteFriendReq{
|
||||
@@ -136,13 +135,13 @@ func CallbackAfterDeleteFriend(ctx context.Context, req *pbfriend.DeleteFriendRe
|
||||
FriendUserID: req.FriendUserID,
|
||||
}
|
||||
resp := &cbapi.CallbackAfterDeleteFriendResp{}
|
||||
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackAfterDeleteFriend); err != nil {
|
||||
if err := http.CallBackPostReturn(ctx, globalConfig.Callback.CallbackUrl, cbReq, resp, globalConfig.Callback.CallbackAfterDeleteFriend); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func CallbackBeforeImportFriends(ctx context.Context, req *pbfriend.ImportFriendReq) error {
|
||||
if !config.Config.Callback.CallbackBeforeImportFriends.Enable {
|
||||
func CallbackBeforeImportFriends(ctx context.Context, globalConfig *config.GlobalConfig, req *pbfriend.ImportFriendReq) error {
|
||||
if !globalConfig.Callback.CallbackBeforeImportFriends.Enable {
|
||||
return nil
|
||||
}
|
||||
cbReq := &cbapi.CallbackBeforeImportFriendsReq{
|
||||
@@ -151,7 +150,7 @@ func CallbackBeforeImportFriends(ctx context.Context, req *pbfriend.ImportFriend
|
||||
FriendUserIDs: req.FriendUserIDs,
|
||||
}
|
||||
resp := &cbapi.CallbackBeforeImportFriendsResp{}
|
||||
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeImportFriends); err != nil {
|
||||
if err := http.CallBackPostReturn(ctx, globalConfig.Callback.CallbackUrl, cbReq, resp, globalConfig.Callback.CallbackBeforeImportFriends); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(resp.FriendUserIDs) != 0 {
|
||||
@@ -159,8 +158,8 @@ func CallbackBeforeImportFriends(ctx context.Context, req *pbfriend.ImportFriend
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func CallbackAfterImportFriends(ctx context.Context, req *pbfriend.ImportFriendReq) error {
|
||||
if !config.Config.Callback.CallbackAfterImportFriends.Enable {
|
||||
func CallbackAfterImportFriends(ctx context.Context, globalConfig *config.GlobalConfig, req *pbfriend.ImportFriendReq) error {
|
||||
if !globalConfig.Callback.CallbackAfterImportFriends.Enable {
|
||||
return nil
|
||||
}
|
||||
cbReq := &cbapi.CallbackAfterImportFriendsReq{
|
||||
@@ -169,14 +168,14 @@ func CallbackAfterImportFriends(ctx context.Context, req *pbfriend.ImportFriendR
|
||||
FriendUserIDs: req.FriendUserIDs,
|
||||
}
|
||||
resp := &cbapi.CallbackAfterImportFriendsResp{}
|
||||
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackAfterImportFriends); err != nil {
|
||||
if err := http.CallBackPostReturn(ctx, globalConfig.Callback.CallbackUrl, cbReq, resp, globalConfig.Callback.CallbackAfterImportFriends); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CallbackAfterRemoveBlack(ctx context.Context, req *pbfriend.RemoveBlackReq) error {
|
||||
if !config.Config.Callback.CallbackAfterRemoveBlack.Enable {
|
||||
func CallbackAfterRemoveBlack(ctx context.Context, globalConfig *config.GlobalConfig, req *pbfriend.RemoveBlackReq) error {
|
||||
if !globalConfig.Callback.CallbackAfterRemoveBlack.Enable {
|
||||
return nil
|
||||
}
|
||||
cbReq := &cbapi.CallbackAfterRemoveBlackReq{
|
||||
@@ -185,7 +184,7 @@ func CallbackAfterRemoveBlack(ctx context.Context, req *pbfriend.RemoveBlackReq)
|
||||
BlackUserID: req.BlackUserID,
|
||||
}
|
||||
resp := &cbapi.CallbackAfterRemoveBlackResp{}
|
||||
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackAfterRemoveBlack); err != nil {
|
||||
if err := http.CallBackPostReturn(ctx, globalConfig.Callback.CallbackUrl, cbReq, resp, globalConfig.Callback.CallbackAfterRemoveBlack); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -31,16 +31,23 @@ import (
|
||||
|
||||
"github.com/OpenIMSDK/protocol/constant"
|
||||
pbfriend "github.com/OpenIMSDK/protocol/friend"
|
||||
"github.com/OpenIMSDK/protocol/sdkws"
|
||||
registry "github.com/OpenIMSDK/tools/discoveryregistry"
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
"github.com/OpenIMSDK/tools/log"
|
||||
"github.com/OpenIMSDK/tools/tx"
|
||||
"github.com/OpenIMSDK/tools/utils"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/convert"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/db/cache"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/db/controller"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/db/mgo"
|
||||
tablerelation "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/db/unrelation"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient/notification"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type friendServer struct {
|
||||
@@ -50,42 +57,44 @@ type friendServer struct {
|
||||
notificationSender *notification.FriendNotificationSender
|
||||
conversationRpcClient rpcclient.ConversationRpcClient
|
||||
RegisterCenter registry.SvcDiscoveryRegistry
|
||||
config *config.GlobalConfig
|
||||
}
|
||||
|
||||
func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
||||
func Start(config *config.GlobalConfig, client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
||||
// Initialize MongoDB
|
||||
mongo, err := unrelation.NewMongo()
|
||||
mongo, err := unrelation.NewMongo(config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Initialize Redis
|
||||
rdb, err := cache.NewRedis()
|
||||
rdb, err := cache.NewRedis(config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
friendMongoDB, err := mgo.NewFriendMongo(mongo.GetDatabase())
|
||||
friendMongoDB, err := mgo.NewFriendMongo(mongo.GetDatabase(config.Mongo.Database))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
friendRequestMongoDB, err := mgo.NewFriendRequestMongo(mongo.GetDatabase())
|
||||
friendRequestMongoDB, err := mgo.NewFriendRequestMongo(mongo.GetDatabase(config.Mongo.Database))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
blackMongoDB, err := mgo.NewBlackMongo(mongo.GetDatabase())
|
||||
blackMongoDB, err := mgo.NewBlackMongo(mongo.GetDatabase(config.Mongo.Database))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Initialize RPC clients
|
||||
userRpcClient := rpcclient.NewUserRpcClient(client)
|
||||
msgRpcClient := rpcclient.NewMessageRpcClient(client)
|
||||
userRpcClient := rpcclient.NewUserRpcClient(client, config)
|
||||
msgRpcClient := rpcclient.NewMessageRpcClient(client, config)
|
||||
|
||||
// Initialize notification sender
|
||||
notificationSender := notification.NewFriendNotificationSender(
|
||||
config,
|
||||
&msgRpcClient,
|
||||
notification.WithRpcFunc(userRpcClient.GetUsersInfo),
|
||||
)
|
||||
@@ -104,7 +113,8 @@ func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
||||
userRpcClient: &userRpcClient,
|
||||
notificationSender: notificationSender,
|
||||
RegisterCenter: client,
|
||||
conversationRpcClient: rpcclient.NewConversationRpcClient(client),
|
||||
conversationRpcClient: rpcclient.NewConversationRpcClient(client, config),
|
||||
config: config,
|
||||
})
|
||||
|
||||
return nil
|
||||
@@ -112,15 +122,14 @@ func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
||||
|
||||
// ok.
|
||||
func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) (resp *pbfriend.ApplyToAddFriendResp, err error) {
|
||||
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
||||
resp = &pbfriend.ApplyToAddFriendResp{}
|
||||
if err := authverify.CheckAccessV3(ctx, req.FromUserID); err != nil {
|
||||
if err := authverify.CheckAccessV3(ctx, req.FromUserID, s.config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if req.ToUserID == req.FromUserID {
|
||||
return nil, errs.ErrCanNotAddYourself.Wrap()
|
||||
return nil, errs.ErrCanNotAddYourself.Wrap("req.ToUserID", req.ToUserID)
|
||||
}
|
||||
if err = CallbackBeforeAddFriend(ctx, req); err != nil && err != errs.ErrCallbackContinue {
|
||||
if err = CallbackBeforeAddFriend(ctx, s.config, req); err != nil && err != errs.ErrCallbackContinue {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := s.userRpcClient.GetUsersInfoMap(ctx, []string{req.ToUserID, req.FromUserID}); err != nil {
|
||||
@@ -137,7 +146,7 @@ func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.Apply
|
||||
return nil, err
|
||||
}
|
||||
s.notificationSender.FriendApplicationAddNotification(ctx, req)
|
||||
if err = CallbackAfterAddFriend(ctx, req); err != nil && err != errs.ErrCallbackContinue {
|
||||
if err = CallbackAfterAddFriend(ctx, s.config, req); err != nil && err != errs.ErrCallbackContinue {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
@@ -146,7 +155,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) {
|
||||
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
||||
if err := authverify.CheckAdmin(ctx); err != nil {
|
||||
if err := authverify.CheckAdmin(ctx, s.config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := s.userRpcClient.GetUsersInfo(ctx, append([]string{req.OwnerUserID}, req.FriendUserIDs...)); err != nil {
|
||||
@@ -158,7 +167,7 @@ func (s *friendServer) ImportFriends(ctx context.Context, req *pbfriend.ImportFr
|
||||
if utils.Duplicate(req.FriendUserIDs) {
|
||||
return nil, errs.ErrArgs.Wrap("friend userID repeated")
|
||||
}
|
||||
if err := CallbackBeforeImportFriends(ctx, req); err != nil {
|
||||
if err := CallbackBeforeImportFriends(ctx, s.config, req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -172,7 +181,7 @@ func (s *friendServer) ImportFriends(ctx context.Context, req *pbfriend.ImportFr
|
||||
HandleResult: constant.FriendResponseAgree,
|
||||
})
|
||||
}
|
||||
if err := CallbackAfterImportFriends(ctx, req); err != nil {
|
||||
if err := CallbackAfterImportFriends(ctx, s.config, req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &pbfriend.ImportFriendResp{}, nil
|
||||
@@ -182,7 +191,7 @@ func (s *friendServer) ImportFriends(ctx context.Context, req *pbfriend.ImportFr
|
||||
func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbfriend.RespondFriendApplyReq) (resp *pbfriend.RespondFriendApplyResp, err error) {
|
||||
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
||||
resp = &pbfriend.RespondFriendApplyResp{}
|
||||
if err := authverify.CheckAccessV3(ctx, req.ToUserID); err != nil {
|
||||
if err := authverify.CheckAccessV3(ctx, req.ToUserID, s.config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -193,7 +202,7 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbfriend.Res
|
||||
HandleResult: req.HandleResult,
|
||||
}
|
||||
if req.HandleResult == constant.FriendResponseAgree {
|
||||
if err := CallbackBeforeAddFriendAgree(ctx, req); err != nil && err != errs.ErrCallbackContinue {
|
||||
if err := CallbackBeforeAddFriendAgree(ctx, s.config, req); err != nil && err != errs.ErrCallbackContinue {
|
||||
return nil, err
|
||||
}
|
||||
err := s.friendDatabase.AgreeFriendRequest(ctx, &friendRequest)
|
||||
@@ -229,7 +238,7 @@ func (s *friendServer) DeleteFriend(ctx context.Context, req *pbfriend.DeleteFri
|
||||
return nil, err
|
||||
}
|
||||
s.notificationSender.FriendDeletedNotification(ctx, req)
|
||||
if err := CallbackAfterDeleteFriend(ctx, req); err != nil {
|
||||
if err := CallbackAfterDeleteFriend(ctx, s.config, req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
@@ -239,7 +248,7 @@ func (s *friendServer) DeleteFriend(ctx context.Context, req *pbfriend.DeleteFri
|
||||
func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbfriend.SetFriendRemarkReq) (resp *pbfriend.SetFriendRemarkResp, err error) {
|
||||
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
||||
|
||||
if err = CallbackBeforeSetFriendRemark(ctx, req); err != nil && err != errs.ErrCallbackContinue {
|
||||
if err = CallbackBeforeSetFriendRemark(ctx, s.config, req); err != nil && err != errs.ErrCallbackContinue {
|
||||
return nil, err
|
||||
}
|
||||
resp = &pbfriend.SetFriendRemarkResp{}
|
||||
@@ -253,7 +262,7 @@ func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbfriend.SetFri
|
||||
if err := s.friendDatabase.UpdateRemark(ctx, req.OwnerUserID, req.FriendUserID, req.Remark); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := CallbackAfterSetFriendRemark(ctx, req); err != nil && err != errs.ErrCallbackContinue {
|
||||
if err := CallbackAfterSetFriendRemark(ctx, s.config, req); err != nil && err != errs.ErrCallbackContinue {
|
||||
return nil, err
|
||||
}
|
||||
s.notificationSender.FriendRemarkSetNotification(ctx, req.OwnerUserID, req.FriendUserID)
|
||||
@@ -277,6 +286,7 @@ func (s *friendServer) GetDesignatedFriends(ctx context.Context, req *pbfriend.G
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// Get the list of friend requests sent out proactively.
|
||||
func (s *friendServer) GetDesignatedFriendsApply(ctx context.Context,
|
||||
req *pbfriend.GetDesignatedFriendsApplyReq) (resp *pbfriend.GetDesignatedFriendsApplyResp, err error) {
|
||||
friendRequests, err := s.friendDatabase.FindBothFriendRequests(ctx, req.FromUserID, req.ToUserID)
|
||||
@@ -291,7 +301,7 @@ func (s *friendServer) GetDesignatedFriendsApply(ctx context.Context,
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// ok 获取接收到的好友申请(即别人主动申请的).
|
||||
// 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) {
|
||||
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
||||
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
|
||||
@@ -310,7 +320,6 @@ func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbf
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// ok 获取主动发出去的好友申请列表.
|
||||
func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *pbfriend.GetPaginationFriendsApplyFromReq) (resp *pbfriend.GetPaginationFriendsApplyFromResp, err error) {
|
||||
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
||||
resp = &pbfriend.GetPaginationFriendsApplyFromResp{}
|
||||
|
||||
Reference in New Issue
Block a user