Merge remote-tracking branch 'origin/errcode' into errcode

test-errcode
Gordon 2 years ago
commit 2afe26336d

@ -4,7 +4,7 @@ go 1.18
require (
firebase.google.com/go v3.13.0+incompatible
github.com/OpenIMSDK/openKeeper v0.9.9-0.20230426053850-80d254440004
github.com/OpenIMSDK/openKeeper v0.9.9-0.20230509114426-eb05252b1e67
github.com/OpenIMSDK/open_utils v1.0.8
github.com/Shopify/sarama v1.32.0
github.com/antonfisher/nested-logrus-formatter v1.3.1

@ -391,6 +391,8 @@ github.com/OpenIMSDK/openKeeper v0.0.6 h1:0eseL/h+evxZAM5Dqs85FEDbDFkTjpVwHBSINQ
github.com/OpenIMSDK/openKeeper v0.0.6/go.mod h1:HwHgo+p3E+aAeiLOSyDwVB2zFJtu+QvnFNlfNjFG9vA=
github.com/OpenIMSDK/openKeeper v0.9.9-0.20230426053850-80d254440004 h1:+1t9eKPKV/NyQARgVUv6TgOWSf8uKu8rkS41+utSIMk=
github.com/OpenIMSDK/openKeeper v0.9.9-0.20230426053850-80d254440004/go.mod h1:HwHgo+p3E+aAeiLOSyDwVB2zFJtu+QvnFNlfNjFG9vA=
github.com/OpenIMSDK/openKeeper v0.9.9-0.20230509114426-eb05252b1e67 h1:I6QLciX4LlavBMNyeqkp90DJV+uKcwke7NZ9OKMIjV8=
github.com/OpenIMSDK/openKeeper v0.9.9-0.20230509114426-eb05252b1e67/go.mod h1:HwHgo+p3E+aAeiLOSyDwVB2zFJtu+QvnFNlfNjFG9vA=
github.com/OpenIMSDK/open_utils v1.0.8 h1:IopxWgJwEF5ZAPsRuiZZOfcxNOQOCt/p8VDENcHN9r4=
github.com/OpenIMSDK/open_utils v1.0.8/go.mod h1:FLoaQblWUVKQgqt2LrNzfSZLT6D3DICBn1kcOMDLUOI=
github.com/Shopify/sarama v1.29.0 h1:ARid8o8oieau9XrHI55f/L3EoRAhm9px6sonbD7yuUE=

@ -5,6 +5,7 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group"
@ -26,6 +27,7 @@ func (o *Group) client(ctx context.Context) (group.GroupClient, error) {
if err != nil {
return nil, err
}
log.ZDebug(ctx, "get conn", "local", o.c.GetClientLocalConns())
return group.NewGroupClient(conn), nil
}

@ -10,7 +10,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
@ -157,10 +156,11 @@ func (m *Message) SendMessage(c *gin.Context) {
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
return
}
if !tokenverify.IsAppManagerUid(c) {
apiresp.GinError(c, errs.ErrNoPermission.Wrap("only app manager can send message"))
return
}
// todo
//if !tokenverify.IsAppManagerUid(c) {
// apiresp.GinError(c, errs.ErrNoPermission.Wrap("only app manager can send message"))
// return
//}
var data interface{}
switch params.ContentType {

@ -67,9 +67,10 @@ func NewGinRouter(zk discoveryregistry.SvcDiscoveryRegistry, rdb redis.Universal
friendRouterGroup.POST("/import_friend", f.ImportFriends) //1
friendRouterGroup.POST("/is_friend", f.IsFriend) //1
}
groupRouterGroup := r.Group("/group")
g := NewGroup(zk)
groupRouterGroup := r.Group("/group")
{
groupRouterGroup.Use(mw.GinParseToken(rdb))
groupRouterGroup.POST("/create_group", g.NewCreateGroup) //1
groupRouterGroup.POST("/set_group_info", g.NewSetGroupInfo) //1

@ -1,6 +1,8 @@
package cmd
import (
"errors"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/startrpc"
"github.com/spf13/cobra"
@ -25,5 +27,8 @@ func (a *RpcCmd) Exec() error {
}
func (a *RpcCmd) StartSvr(name string, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error) error {
if a.GetPortFlag() == 0 {
return errors.New("port is required")
}
return startrpc.Start(a.GetPortFlag(), name, a.GetPrometheusPortFlag(), rpcFn)
}

@ -59,7 +59,7 @@ func (f *FriendRequestGorm) FindToUserID(ctx context.Context, toUserID string, p
if err != nil {
return nil, 0, utils.Wrap(err, "")
}
err = utils.Wrap(f.db(ctx).Where("to_user_id = ? ", toUserID).Limit(int(showNumber)).Offset(int(pageNumber*showNumber-1)).Find(&friendRequests).Error, "")
err = utils.Wrap(f.db(ctx).Where("to_user_id = ? ", toUserID).Limit(int(showNumber)).Offset(int(pageNumber-1)*int(showNumber)).Find(&friendRequests).Error, "")
return
}
@ -69,6 +69,6 @@ func (f *FriendRequestGorm) FindFromUserID(ctx context.Context, fromUserID strin
if err != nil {
return nil, 0, utils.Wrap(err, "")
}
err = utils.Wrap(f.db(ctx).Where("from_user_id = ? ", fromUserID).Limit(int(showNumber)).Offset(int(pageNumber*showNumber-1)).Find(&friendRequests).Error, "")
err = utils.Wrap(f.db(ctx).Where("from_user_id = ? ", fromUserID).Limit(int(showNumber)).Offset(int(pageNumber-1)*int(showNumber)).Find(&friendRequests).Error, "")
return
}

@ -4,12 +4,15 @@ import (
"context"
"google.golang.org/grpc"
"google.golang.org/grpc/resolver"
)
type Conn interface {
GetConns(ctx context.Context, serviceName string, opts ...grpc.DialOption) ([]*grpc.ClientConn, error)
GetConn(ctx context.Context, serviceName string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
AddOption(opts ...grpc.DialOption)
// do not use this method for call rpc
GetClientLocalConns() map[string][]resolver.Address
}
type SvcDiscoveryRegistry interface {

Loading…
Cancel
Save