mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-05 05:12:45 +08:00
feat: update webhookBeforeMemberJoinGroup to batch method. (#2459)
* update protocol in go mod. * add debug log in writePongMsg. * update log level. * add Warn log in writePongMsg. * add debug log. * feat: update webhookBeforeMemberJoinGroup to batch method. * feat: update version field implement. * update webhook implement contents. * update method field and contents. * update callbackCommand field. * fix: add correct fields. * update struct tags.
This commit is contained in:
parent
ed0ab58a9e
commit
fb689618d8
1
.env
1
.env
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
MONGO_IMAGE=mongo:6.0.2
|
MONGO_IMAGE=mongo:6.0.2
|
||||||
REDIS_IMAGE=redis:7.0.0
|
REDIS_IMAGE=redis:7.0.0
|
||||||
ZOOKEEPER_IMAGE=bitnami/zookeeper:3.8
|
ZOOKEEPER_IMAGE=bitnami/zookeeper:3.8
|
||||||
|
@ -397,11 +397,9 @@ func (c *Client) writePongMsg(appData string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.ZDebug(c.ctx, "write Pong Msg in Server", "appData", appData)
|
|
||||||
c.w.Lock()
|
c.w.Lock()
|
||||||
defer c.w.Unlock()
|
defer c.w.Unlock()
|
||||||
|
|
||||||
log.ZDebug(c.ctx, "write Pong Msg in Server", "appData", appData)
|
|
||||||
err := c.conn.SetWriteDeadline(writeWait)
|
err := c.conn.SetWriteDeadline(writeWait)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZWarn(c.ctx, "SetWriteDeadline in Server have error", errs.Wrap(err), "writeWait", writeWait, "appData", appData)
|
log.ZWarn(c.ctx, "SetWriteDeadline in Server have error", errs.Wrap(err), "writeWait", writeWait, "appData", appData)
|
||||||
@ -412,6 +410,5 @@ func (c *Client) writePongMsg(appData string) error {
|
|||||||
log.ZWarn(c.ctx, "Write Message have error", errs.Wrap(err), "Pong msg", PongMessage)
|
log.ZWarn(c.ctx, "Write Message have error", errs.Wrap(err), "Pong msg", PongMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.ZDebug(c.ctx, "write message is success", "appdata", appData, "closed err", c.closedErr)
|
|
||||||
return errs.Wrap(err)
|
return errs.Wrap(err)
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ package group
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/apistruct"
|
"github.com/openimsdk/open-im-server/v3/pkg/apistruct"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/callbackstruct"
|
"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/config"
|
||||||
@ -27,7 +29,6 @@ import (
|
|||||||
"github.com/openimsdk/tools/log"
|
"github.com/openimsdk/tools/log"
|
||||||
"github.com/openimsdk/tools/mcontext"
|
"github.com/openimsdk/tools/mcontext"
|
||||||
"github.com/openimsdk/tools/utils/datautil"
|
"github.com/openimsdk/tools/utils/datautil"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// CallbackBeforeCreateGroup callback before create group.
|
// CallbackBeforeCreateGroup callback before create group.
|
||||||
@ -100,27 +101,45 @@ func (s *groupServer) webhookAfterCreateGroup(ctx context.Context, after *config
|
|||||||
s.webhookClient.AsyncPost(ctx, cbReq.GetCallbackCommand(), cbReq, &callbackstruct.CallbackAfterCreateGroupResp{}, after)
|
s.webhookClient.AsyncPost(ctx, cbReq.GetCallbackCommand(), cbReq, &callbackstruct.CallbackAfterCreateGroupResp{}, after)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) webhookBeforeMemberJoinGroup(ctx context.Context, before *config.BeforeConfig, groupMember *model.GroupMember, groupEx string) error {
|
func (s *groupServer) webhookBeforeMembersJoinGroup(ctx context.Context, before *config.BeforeConfig, groupMembers []*model.GroupMember, groupID string, groupEx string) error {
|
||||||
return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
|
return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
|
||||||
cbReq := &callbackstruct.CallbackBeforeMemberJoinGroupReq{
|
groupMembersMap := datautil.SliceToMap(groupMembers, func(e *model.GroupMember) string {
|
||||||
CallbackCommand: callbackstruct.CallbackBeforeMemberJoinGroupCommand,
|
return e.UserID
|
||||||
GroupID: groupMember.GroupID,
|
})
|
||||||
UserID: groupMember.UserID,
|
var groupMembersCallback []*callbackstruct.CallbackGroupMember
|
||||||
Ex: groupMember.Ex,
|
|
||||||
|
for _, member := range groupMembers {
|
||||||
|
groupMembersCallback = append(groupMembersCallback, &callbackstruct.CallbackGroupMember{
|
||||||
|
UserID: member.UserID,
|
||||||
|
Ex: member.Ex,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
cbReq := &callbackstruct.CallbackBeforeMembersJoinGroupReq{
|
||||||
|
CallbackCommand: callbackstruct.CallbackBeforeMembersJoinGroupCommand,
|
||||||
|
GroupID: groupID,
|
||||||
|
MembersList: groupMembersCallback,
|
||||||
GroupEx: groupEx,
|
GroupEx: groupEx,
|
||||||
}
|
}
|
||||||
resp := &callbackstruct.CallbackBeforeMemberJoinGroupResp{}
|
resp := &callbackstruct.CallbackBeforeMembersJoinGroupResp{}
|
||||||
|
|
||||||
if err := s.webhookClient.SyncPost(ctx, cbReq.GetCallbackCommand(), cbReq, resp, before); err != nil {
|
if err := s.webhookClient.SyncPost(ctx, cbReq.GetCallbackCommand(), cbReq, resp, before); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.MuteEndTime != nil {
|
for _, memberCallbackResp := range resp.MemberCallbackList {
|
||||||
groupMember.MuteEndTime = time.UnixMilli(*resp.MuteEndTime)
|
if _, ok := groupMembersMap[(*memberCallbackResp.UserID)]; ok {
|
||||||
|
if memberCallbackResp.MuteEndTime != nil {
|
||||||
|
groupMembersMap[(*memberCallbackResp.UserID)].MuteEndTime = time.UnixMilli(*memberCallbackResp.MuteEndTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
datautil.NotNilReplace(&groupMembersMap[(*memberCallbackResp.UserID)].FaceURL, memberCallbackResp.FaceURL)
|
||||||
|
datautil.NotNilReplace(&groupMembersMap[(*memberCallbackResp.UserID)].Ex, memberCallbackResp.Ex)
|
||||||
|
datautil.NotNilReplace(&groupMembersMap[(*memberCallbackResp.UserID)].Nickname, memberCallbackResp.Nickname)
|
||||||
|
datautil.NotNilReplace(&groupMembersMap[(*memberCallbackResp.UserID)].RoleLevel, memberCallbackResp.RoleLevel)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
datautil.NotNilReplace(&groupMember.FaceURL, resp.FaceURL)
|
|
||||||
datautil.NotNilReplace(&groupMember.Ex, resp.Ex)
|
|
||||||
datautil.NotNilReplace(&groupMember.Nickname, resp.Nickname)
|
|
||||||
datautil.NotNilReplace(&groupMember.RoleLevel, resp.RoleLevel)
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -244,10 +263,13 @@ func (s *groupServer) webhookBeforeInviteUserToGroup(ctx context.Context, before
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(resp.RefusedMembersAccount) > 0 {
|
// Handle the scenario where certain members are refused
|
||||||
// Handle the scenario where certain members are refused
|
// You might want to update the req.Members list or handle it as per your business logic
|
||||||
// You might want to update the req.Members list or handle it as per your business logic
|
|
||||||
}
|
// if len(resp.RefusedMembersAccount) > 0 {
|
||||||
|
// implement members are refused
|
||||||
|
// }
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbgroup.CreateGroupR
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
joinGroup := func(userID string, roleLevel int32) error {
|
joinGroupFunc := func(userID string, roleLevel int32) {
|
||||||
groupMember := &model.GroupMember{
|
groupMember := &model.GroupMember{
|
||||||
GroupID: group.GroupID,
|
GroupID: group.GroupID,
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
@ -258,25 +258,23 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbgroup.CreateGroupR
|
|||||||
MuteEndTime: time.UnixMilli(0),
|
MuteEndTime: time.UnixMilli(0),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.webhookBeforeMemberJoinGroup(ctx, &s.config.WebhooksConfig.BeforeMemberJoinGroup, groupMember, group.Ex); err != nil && err != servererrs.ErrCallbackContinue {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
groupMembers = append(groupMembers, groupMember)
|
groupMembers = append(groupMembers, groupMember)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
if err := joinGroup(req.OwnerUserID, constant.GroupOwner); err != nil {
|
|
||||||
|
joinGroupFunc(req.OwnerUserID, constant.GroupOwner)
|
||||||
|
|
||||||
|
for _, userID := range req.AdminUserIDs {
|
||||||
|
joinGroupFunc(userID, constant.GroupAdmin)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, userID := range req.MemberUserIDs {
|
||||||
|
joinGroupFunc(userID, constant.GroupOrdinaryUsers)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := s.webhookBeforeMembersJoinGroup(ctx, &s.config.WebhooksConfig.BeforeMemberJoinGroup, groupMembers, group.GroupID, group.Ex); err != nil && err != servererrs.ErrCallbackContinue {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, userID := range req.AdminUserIDs {
|
|
||||||
if err := joinGroup(userID, constant.GroupAdmin); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, userID := range req.MemberUserIDs {
|
|
||||||
if err := joinGroup(userID, constant.GroupOrdinaryUsers); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err := s.db.CreateGroup(ctx, []*model.Group{group}, groupMembers); err != nil {
|
if err := s.db.CreateGroup(ctx, []*model.Group{group}, groupMembers); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -442,12 +440,13 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite
|
|||||||
MuteEndTime: time.UnixMilli(0),
|
MuteEndTime: time.UnixMilli(0),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.webhookBeforeMemberJoinGroup(ctx, &s.config.WebhooksConfig.BeforeMemberJoinGroup, member, group.Ex); err != nil && err != servererrs.ErrCallbackContinue {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
groupMembers = append(groupMembers, member)
|
groupMembers = append(groupMembers, member)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := s.webhookBeforeMembersJoinGroup(ctx, &s.config.WebhooksConfig.BeforeMemberJoinGroup, groupMembers, group.GroupID, group.Ex); err != nil && err != servererrs.ErrCallbackContinue {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
if err := s.db.CreateGroup(ctx, nil, groupMembers); err != nil {
|
if err := s.db.CreateGroup(ctx, nil, groupMembers); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -811,9 +810,9 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbgroup
|
|||||||
MuteEndTime: time.Unix(0, 0),
|
MuteEndTime: time.Unix(0, 0),
|
||||||
InviterUserID: groupRequest.InviterUserID,
|
InviterUserID: groupRequest.InviterUserID,
|
||||||
OperatorUserID: mcontext.GetOpUserID(ctx),
|
OperatorUserID: mcontext.GetOpUserID(ctx),
|
||||||
Ex: groupRequest.Ex,
|
|
||||||
}
|
}
|
||||||
if err := s.webhookBeforeMemberJoinGroup(ctx, &s.config.WebhooksConfig.BeforeMemberJoinGroup, member, group.Ex); err != nil && err != servererrs.ErrCallbackContinue {
|
|
||||||
|
if err := s.webhookBeforeMembersJoinGroup(ctx, &s.config.WebhooksConfig.BeforeMemberJoinGroup, []*model.GroupMember{member}, group.GroupID, group.Ex); err != nil && err != servererrs.ErrCallbackContinue {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -882,7 +881,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq)
|
|||||||
MuteEndTime: time.UnixMilli(0),
|
MuteEndTime: time.UnixMilli(0),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.webhookBeforeMemberJoinGroup(ctx, &s.config.WebhooksConfig.BeforeMemberJoinGroup, groupMember, group.Ex); err != nil && err != servererrs.ErrCallbackContinue {
|
if err := s.webhookBeforeMembersJoinGroup(ctx, &s.config.WebhooksConfig.BeforeMemberJoinGroup, []*model.GroupMember{groupMember}, group.GroupID, group.Ex); err != nil && err != servererrs.ErrCallbackContinue {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -898,6 +897,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq)
|
|||||||
|
|
||||||
return &pbgroup.JoinGroupResp{}, nil
|
return &pbgroup.JoinGroupResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
groupRequest := model.GroupRequest{
|
groupRequest := model.GroupRequest{
|
||||||
UserID: req.InviterUserID,
|
UserID: req.InviterUserID,
|
||||||
ReqMsg: req.ReqMessage,
|
ReqMsg: req.ReqMessage,
|
||||||
|
@ -56,7 +56,7 @@ const (
|
|||||||
CallbackBeforeUpdateUserInfoCommand = "callbackBeforeUpdateUserInfoCommand"
|
CallbackBeforeUpdateUserInfoCommand = "callbackBeforeUpdateUserInfoCommand"
|
||||||
CallbackBeforeCreateGroupCommand = "callbackBeforeCreateGroupCommand"
|
CallbackBeforeCreateGroupCommand = "callbackBeforeCreateGroupCommand"
|
||||||
CallbackAfterCreateGroupCommand = "callbackAfterCreateGroupCommand"
|
CallbackAfterCreateGroupCommand = "callbackAfterCreateGroupCommand"
|
||||||
CallbackBeforeMemberJoinGroupCommand = "callbackBeforeMemberJoinGroupCommand"
|
CallbackBeforeMembersJoinGroupCommand = "callbackBeforeMembersJoinGroupCommand"
|
||||||
CallbackBeforeSetGroupMemberInfoCommand = "callbackBeforeSetGroupMemberInfoCommand"
|
CallbackBeforeSetGroupMemberInfoCommand = "callbackBeforeSetGroupMemberInfoCommand"
|
||||||
CallbackAfterSetGroupMemberInfoCommand = "callbackAfterSetGroupMemberInfoCommand"
|
CallbackAfterSetGroupMemberInfoCommand = "callbackAfterSetGroupMemberInfoCommand"
|
||||||
)
|
)
|
||||||
|
@ -59,16 +59,20 @@ type CallbackAfterCreateGroupResp struct {
|
|||||||
CommonCallbackResp
|
CommonCallbackResp
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforeMemberJoinGroupReq struct {
|
type CallbackGroupMember struct {
|
||||||
CallbackCommand `json:"callbackCommand"`
|
UserID string `json:"userID"`
|
||||||
GroupID string `json:"groupID"`
|
Ex string `json:"ex"`
|
||||||
UserID string `json:"userID"`
|
|
||||||
Ex string `json:"ex"`
|
|
||||||
GroupEx string `json:"groupEx"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforeMemberJoinGroupResp struct {
|
type CallbackBeforeMembersJoinGroupReq struct {
|
||||||
CommonCallbackResp
|
CallbackCommand `json:"callbackCommand"`
|
||||||
|
GroupID string `json:"groupID"`
|
||||||
|
MembersList []*CallbackGroupMember `json:"memberList"`
|
||||||
|
GroupEx string `json:"groupEx"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MemberJoinGroupCallBack struct {
|
||||||
|
UserID *string `json:"userID"`
|
||||||
Nickname *string `json:"nickname"`
|
Nickname *string `json:"nickname"`
|
||||||
FaceURL *string `json:"faceURL"`
|
FaceURL *string `json:"faceURL"`
|
||||||
RoleLevel *int32 `json:"roleLevel"`
|
RoleLevel *int32 `json:"roleLevel"`
|
||||||
@ -76,6 +80,11 @@ type CallbackBeforeMemberJoinGroupResp struct {
|
|||||||
Ex *string `json:"ex"`
|
Ex *string `json:"ex"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CallbackBeforeMembersJoinGroupResp struct {
|
||||||
|
CommonCallbackResp
|
||||||
|
MemberCallbackList []*MemberJoinGroupCallBack `json:"memberCallbackList"`
|
||||||
|
}
|
||||||
|
|
||||||
type CallbackBeforeSetGroupMemberInfoReq struct {
|
type CallbackBeforeSetGroupMemberInfoReq struct {
|
||||||
CallbackCommand `json:"callbackCommand"`
|
CallbackCommand `json:"callbackCommand"`
|
||||||
GroupID string `json:"groupID"`
|
GroupID string `json:"groupID"`
|
||||||
|
@ -16,8 +16,9 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/api"
|
"github.com/openimsdk/open-im-server/v3/internal/api"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/version"
|
||||||
"github.com/openimsdk/tools/system/program"
|
"github.com/openimsdk/tools/system/program"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -38,7 +39,7 @@ func NewApiCmd() *ApiCmd {
|
|||||||
DiscoveryConfigFilename: &apiConfig.Discovery,
|
DiscoveryConfigFilename: &apiConfig.Discovery,
|
||||||
}
|
}
|
||||||
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
||||||
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
|
ret.ctx = context.WithValue(context.Background(), "version", version.Version)
|
||||||
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
||||||
return ret.runE()
|
return ret.runE()
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,10 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/auth"
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/auth"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/version"
|
||||||
"github.com/openimsdk/tools/system/program"
|
"github.com/openimsdk/tools/system/program"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -40,7 +41,7 @@ func NewAuthRpcCmd() *AuthRpcCmd {
|
|||||||
DiscoveryConfigFilename: &authConfig.Discovery,
|
DiscoveryConfigFilename: &authConfig.Discovery,
|
||||||
}
|
}
|
||||||
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
||||||
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
|
ret.ctx = context.WithValue(context.Background(), "version", version.Version)
|
||||||
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
||||||
return ret.runE()
|
return ret.runE()
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,10 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/conversation"
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/conversation"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/version"
|
||||||
"github.com/openimsdk/tools/system/program"
|
"github.com/openimsdk/tools/system/program"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -43,7 +44,7 @@ func NewConversationRpcCmd() *ConversationRpcCmd {
|
|||||||
DiscoveryConfigFilename: &conversationConfig.Discovery,
|
DiscoveryConfigFilename: &conversationConfig.Discovery,
|
||||||
}
|
}
|
||||||
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
||||||
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
|
ret.ctx = context.WithValue(context.Background(), "version", version.Version)
|
||||||
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
||||||
return ret.runE()
|
return ret.runE()
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,9 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/tools"
|
"github.com/openimsdk/open-im-server/v3/internal/tools"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/version"
|
||||||
"github.com/openimsdk/tools/system/program"
|
"github.com/openimsdk/tools/system/program"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -38,7 +39,7 @@ func NewCronTaskCmd() *CronTaskCmd {
|
|||||||
DiscoveryConfigFilename: &cronTaskConfig.Discovery,
|
DiscoveryConfigFilename: &cronTaskConfig.Discovery,
|
||||||
}
|
}
|
||||||
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
||||||
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
|
ret.ctx = context.WithValue(context.Background(), "version", version.Version)
|
||||||
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
||||||
return ret.runE()
|
return ret.runE()
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,10 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/friend"
|
"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/startrpc"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/version"
|
||||||
"github.com/openimsdk/tools/system/program"
|
"github.com/openimsdk/tools/system/program"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -44,7 +45,7 @@ func NewFriendRpcCmd() *FriendRpcCmd {
|
|||||||
DiscoveryConfigFilename: &friendConfig.Discovery,
|
DiscoveryConfigFilename: &friendConfig.Discovery,
|
||||||
}
|
}
|
||||||
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
||||||
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
|
ret.ctx = context.WithValue(context.Background(), "version", version.Version)
|
||||||
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
||||||
return ret.runE()
|
return ret.runE()
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,11 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/group"
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/group"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/versionctx"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/versionctx"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/version"
|
||||||
"github.com/openimsdk/tools/system/program"
|
"github.com/openimsdk/tools/system/program"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -45,7 +46,7 @@ func NewGroupRpcCmd() *GroupRpcCmd {
|
|||||||
DiscoveryConfigFilename: &groupConfig.Discovery,
|
DiscoveryConfigFilename: &groupConfig.Discovery,
|
||||||
}
|
}
|
||||||
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
||||||
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
|
ret.ctx = context.WithValue(context.Background(), "version", version.Version)
|
||||||
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
||||||
return ret.runE()
|
return ret.runE()
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,10 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/msg"
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/msg"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/version"
|
||||||
"github.com/openimsdk/tools/system/program"
|
"github.com/openimsdk/tools/system/program"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -45,7 +46,7 @@ func NewMsgRpcCmd() *MsgRpcCmd {
|
|||||||
DiscoveryConfigFilename: &msgConfig.Discovery,
|
DiscoveryConfigFilename: &msgConfig.Discovery,
|
||||||
}
|
}
|
||||||
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
||||||
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
|
ret.ctx = context.WithValue(context.Background(), "version", version.Version)
|
||||||
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
||||||
return ret.runE()
|
return ret.runE()
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/msggateway"
|
"github.com/openimsdk/open-im-server/v3/internal/msggateway"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/version"
|
||||||
|
|
||||||
"github.com/openimsdk/tools/system/program"
|
"github.com/openimsdk/tools/system/program"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -42,7 +42,7 @@ func NewMsgGatewayCmd() *MsgGatewayCmd {
|
|||||||
DiscoveryConfigFilename: &msgGatewayConfig.Discovery,
|
DiscoveryConfigFilename: &msgGatewayConfig.Discovery,
|
||||||
}
|
}
|
||||||
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
||||||
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
|
ret.ctx = context.WithValue(context.Background(), "version", version.Version)
|
||||||
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
||||||
return ret.runE()
|
return ret.runE()
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,9 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/msgtransfer"
|
"github.com/openimsdk/open-im-server/v3/internal/msgtransfer"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/version"
|
||||||
"github.com/openimsdk/tools/system/program"
|
"github.com/openimsdk/tools/system/program"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -42,7 +43,7 @@ func NewMsgTransferCmd() *MsgTransferCmd {
|
|||||||
DiscoveryConfigFilename: &msgTransferConfig.Discovery,
|
DiscoveryConfigFilename: &msgTransferConfig.Discovery,
|
||||||
}
|
}
|
||||||
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
||||||
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
|
ret.ctx = context.WithValue(context.Background(), "version", version.Version)
|
||||||
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
||||||
return ret.runE()
|
return ret.runE()
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,10 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/push"
|
"github.com/openimsdk/open-im-server/v3/internal/push"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/version"
|
||||||
"github.com/openimsdk/tools/system/program"
|
"github.com/openimsdk/tools/system/program"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -45,7 +46,7 @@ func NewPushRpcCmd() *PushRpcCmd {
|
|||||||
DiscoveryConfigFilename: &pushConfig.Discovery,
|
DiscoveryConfigFilename: &pushConfig.Discovery,
|
||||||
}
|
}
|
||||||
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
||||||
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
|
ret.ctx = context.WithValue(context.Background(), "version", version.Version)
|
||||||
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
||||||
ret.pushConfig.FcmConfigPath = ret.ConfigPath()
|
ret.pushConfig.FcmConfigPath = ret.ConfigPath()
|
||||||
return ret.runE()
|
return ret.runE()
|
||||||
|
@ -19,6 +19,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/version"
|
||||||
"github.com/openimsdk/tools/errs"
|
"github.com/openimsdk/tools/errs"
|
||||||
"github.com/openimsdk/tools/log"
|
"github.com/openimsdk/tools/log"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -138,13 +139,13 @@ func (r *RootCmd) initializeLogger(cmdOpts *CmdOpts) error {
|
|||||||
r.log.StorageLocation,
|
r.log.StorageLocation,
|
||||||
r.log.RemainRotationCount,
|
r.log.RemainRotationCount,
|
||||||
r.log.RotationTime,
|
r.log.RotationTime,
|
||||||
config.Version,
|
version.Version,
|
||||||
r.log.IsSimplify,
|
r.log.IsSimplify,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errs.Wrap(err)
|
return errs.Wrap(err)
|
||||||
}
|
}
|
||||||
return errs.Wrap(log.InitConsoleLogger(r.processName, r.log.RemainLogLevel, r.log.IsJson, config.Version))
|
return errs.Wrap(log.InitConsoleLogger(r.processName, r.log.RemainLogLevel, r.log.IsJson, version.Version))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,9 +16,10 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/third"
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/third"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/version"
|
||||||
"github.com/openimsdk/tools/system/program"
|
"github.com/openimsdk/tools/system/program"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -44,7 +45,7 @@ func NewThirdRpcCmd() *ThirdRpcCmd {
|
|||||||
DiscoveryConfigFilename: &thirdConfig.Discovery,
|
DiscoveryConfigFilename: &thirdConfig.Discovery,
|
||||||
}
|
}
|
||||||
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
||||||
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
|
ret.ctx = context.WithValue(context.Background(), "version", version.Version)
|
||||||
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
||||||
return ret.runE()
|
return ret.runE()
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,10 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/user"
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/user"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/version"
|
||||||
"github.com/openimsdk/tools/system/program"
|
"github.com/openimsdk/tools/system/program"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -45,7 +46,7 @@ func NewUserRpcCmd() *UserRpcCmd {
|
|||||||
DiscoveryConfigFilename: &userConfig.Discovery,
|
DiscoveryConfigFilename: &userConfig.Discovery,
|
||||||
}
|
}
|
||||||
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
|
||||||
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
|
ret.ctx = context.WithValue(context.Background(), "version", version.Version)
|
||||||
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
||||||
return ret.runE()
|
return ret.runE()
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "embed"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
@ -26,9 +25,6 @@ import (
|
|||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed version
|
|
||||||
var Version string
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FileName = "config.yaml"
|
FileName = "config.yaml"
|
||||||
NotificationFileName = "notification.yaml"
|
NotificationFileName = "notification.yaml"
|
||||||
|
@ -1 +0,0 @@
|
|||||||
3.7.0
|
|
1
version/version
Normal file
1
version/version
Normal file
@ -0,0 +1 @@
|
|||||||
|
3.8.0
|
6
version/version.go
Normal file
6
version/version.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package version
|
||||||
|
|
||||||
|
import _ "embed"
|
||||||
|
|
||||||
|
//go:embed version
|
||||||
|
var Version string
|
Loading…
x
Reference in New Issue
Block a user