|
|
@ -16,33 +16,26 @@ package friend
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/OpenIMSDK/tools/tx"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/OpenIMSDK/protocol/sdkws"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/OpenIMSDK/tools/log"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/convert"
|
|
|
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/OpenIMSDK/protocol/constant"
|
|
|
|
"github.com/OpenIMSDK/protocol/constant"
|
|
|
|
pbfriend "github.com/OpenIMSDK/protocol/friend"
|
|
|
|
pbfriend "github.com/OpenIMSDK/protocol/friend"
|
|
|
|
|
|
|
|
"github.com/OpenIMSDK/protocol/sdkws"
|
|
|
|
registry "github.com/OpenIMSDK/tools/discoveryregistry"
|
|
|
|
registry "github.com/OpenIMSDK/tools/discoveryregistry"
|
|
|
|
"github.com/OpenIMSDK/tools/errs"
|
|
|
|
"github.com/OpenIMSDK/tools/errs"
|
|
|
|
|
|
|
|
"github.com/OpenIMSDK/tools/log"
|
|
|
|
|
|
|
|
"github.com/OpenIMSDK/tools/tx"
|
|
|
|
"github.com/OpenIMSDK/tools/utils"
|
|
|
|
"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/cache"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/db/controller"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/db/controller"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/db/mgo"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/db/mgo"
|
|
|
|
tablerelation "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"
|
|
|
|
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/common/db/unrelation"
|
|
|
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient/notification"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient/notification"
|
|
|
|
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type friendServer struct {
|
|
|
|
type friendServer struct {
|
|
|
@ -118,7 +111,7 @@ func Start(config *config.GlobalConfig, client registry.SvcDiscoveryRegistry, se
|
|
|
|
// ok.
|
|
|
|
// ok.
|
|
|
|
func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) (resp *pbfriend.ApplyToAddFriendResp, err error) {
|
|
|
|
func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) (resp *pbfriend.ApplyToAddFriendResp, err error) {
|
|
|
|
resp = &pbfriend.ApplyToAddFriendResp{}
|
|
|
|
resp = &pbfriend.ApplyToAddFriendResp{}
|
|
|
|
if err := authverify.CheckAccessV3(ctx, req.FromUserID,s.config); err != nil {
|
|
|
|
if err := authverify.CheckAccessV3(ctx, req.FromUserID, s.config); err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if req.ToUserID == req.FromUserID {
|
|
|
|
if req.ToUserID == req.FromUserID {
|
|
|
@ -141,7 +134,7 @@ func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.Apply
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s.notificationSender.FriendApplicationAddNotification(ctx, req)
|
|
|
|
s.notificationSender.FriendApplicationAddNotification(ctx, req)
|
|
|
|
if err = CallbackAfterAddFriend(ctx,s.config ,req); err != nil && err != errs.ErrCallbackContinue {
|
|
|
|
if err = CallbackAfterAddFriend(ctx, s.config, req); err != nil && err != errs.ErrCallbackContinue {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return resp, nil
|
|
|
|
return resp, nil
|
|
|
|