mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
group
This commit is contained in:
parent
fa9ff6709d
commit
d1347c3db0
@ -18,7 +18,6 @@ import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msggateway"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||
@ -32,25 +31,26 @@ type Pusher struct {
|
||||
groupLocalCache *localcache.GroupLocalCache
|
||||
conversationLocalCache *localcache.ConversationLocalCache
|
||||
msgClient *rpcclient.MessageRpcClient
|
||||
conversationClient *rpcclient.ConversationRpcClient
|
||||
conversationRpcClient *rpcclient.ConversationRpcClient
|
||||
groupRpcClient *rpcclient.GroupRpcClient
|
||||
successCount int
|
||||
}
|
||||
|
||||
var errNoOfflinePusher = errors.New("no offlinePusher is configured")
|
||||
|
||||
func NewPusher(client discoveryregistry.SvcDiscoveryRegistry, offlinePusher offlinepush.OfflinePusher, database controller.PushDatabase,
|
||||
func NewPusher(discov discoveryregistry.SvcDiscoveryRegistry, offlinePusher offlinepush.OfflinePusher, database controller.PushDatabase,
|
||||
groupLocalCache *localcache.GroupLocalCache, conversationLocalCache *localcache.ConversationLocalCache) *Pusher {
|
||||
|
||||
msgClient := rpcclient.NewMessageRpcClient(client)
|
||||
conversationClient := rpcclient.NewConversationRpcClient(client)
|
||||
msgClient := rpcclient.NewMessageRpcClient(discov)
|
||||
conversationRpcClient := rpcclient.NewConversationRpcClient(discov)
|
||||
groupRpcClient := rpcclient.NewGroupRpcClient(discov)
|
||||
return &Pusher{
|
||||
database: database,
|
||||
client: client,
|
||||
offlinePusher: offlinePusher,
|
||||
groupLocalCache: groupLocalCache,
|
||||
conversationLocalCache: conversationLocalCache,
|
||||
msgClient: &msgClient,
|
||||
conversationClient: &conversationClient,
|
||||
conversationRpcClient: &conversationRpcClient,
|
||||
groupRpcClient: &groupRpcClient,
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,25 +68,13 @@ func NewOfflinePusher(cache cache.MsgModel) offlinepush.OfflinePusher {
|
||||
return offlinePusher
|
||||
}
|
||||
|
||||
func (p *Pusher) DismissGroup(ctx context.Context, groupID string) error {
|
||||
cc, err := p.client.GetConn(ctx, config.Config.RpcRegisterName.OpenImGroupName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = group.NewGroupClient(cc).DismissGroup(ctx, &group.DismissGroupReq{
|
||||
GroupID: groupID,
|
||||
DeleteMember: true,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *Pusher) DeleteMemberAndSetConversationSeq(ctx context.Context, groupID string, userIDs []string) error {
|
||||
conevrsationID := utils.GetConversationIDBySessionType(constant.SuperGroupChatType, groupID)
|
||||
maxSeq, err := p.msgClient.GetConversationMaxSeq(ctx, conevrsationID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return p.conversationClient.SetConversationMaxSeq(ctx, userIDs, conevrsationID, maxSeq)
|
||||
return p.conversationRpcClient.SetConversationMaxSeq(ctx, userIDs, conevrsationID, maxSeq)
|
||||
}
|
||||
|
||||
func (p *Pusher) Push2User(ctx context.Context, userIDs []string, msg *sdkws.MsgData) error {
|
||||
@ -179,7 +167,7 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
|
||||
ctx = mcontext.WithOpUserIDContext(ctx, config.Config.Manager.AppManagerUid[0])
|
||||
}
|
||||
defer func(groupID string) {
|
||||
if err := p.DismissGroup(ctx, groupID); err != nil {
|
||||
if err := p.groupRpcClient.DismissGroup(ctx, groupID); err != nil {
|
||||
log.ZError(ctx, "DismissGroup Notification clear members", err, "groupID", groupID)
|
||||
}
|
||||
}(groupID)
|
||||
|
@ -155,3 +155,11 @@ func (g *GroupRpcClient) GetGroupMemberCache(ctx context.Context, groupID string
|
||||
}
|
||||
return resp.Member, nil
|
||||
}
|
||||
|
||||
func (g *GroupRpcClient) DismissGroup(ctx context.Context, groupID string) error {
|
||||
_, err := g.Client.DismissGroup(ctx, &group.DismissGroupReq{
|
||||
GroupID: groupID,
|
||||
DeleteMember: true,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user