You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/pkg/common/db/localcache/conversation.go

42 lines
1.2 KiB

2 years ago
package localcache
import (
2 years ago
"OpenIM/pkg/common/config"
"OpenIM/pkg/discoveryregistry"
"OpenIM/pkg/proto/conversation"
2 years ago
"context"
"sync"
)
2 years ago
type ConversationLocalCacheInterface interface {
2 years ago
GetRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) ([]string, error)
2 years ago
}
2 years ago
type ConversationLocalCache struct {
lock sync.Mutex
SuperGroupRecvMsgNotNotifyUserIDs map[string][]string
2 years ago
client discoveryregistry.SvcDiscoveryRegistry
2 years ago
}
2 years ago
func NewConversationLocalCache(client discoveryregistry.SvcDiscoveryRegistry) ConversationLocalCache {
2 years ago
return ConversationLocalCache{
SuperGroupRecvMsgNotNotifyUserIDs: make(map[string][]string, 0),
2 years ago
client: client,
2 years ago
}
}
2 years ago
func (g *ConversationLocalCache) GetRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) ([]string, error) {
2 years ago
conn, err := g.client.GetConn(config.Config.RpcRegisterName.OpenImConversationName)
if err != nil {
return nil, err
}
client := conversation.NewConversationClient(conn)
resp, err := client.GetRecvMsgNotNotifyUserIDs(ctx, &conversation.GetRecvMsgNotNotifyUserIDsReq{
GroupID: groupID,
})
if err != nil {
return nil, err
}
return resp.UserIDs, nil
2 years ago
}