Files
open-im-server/pkg/common/db/localcache/conversation.go
T

42 lines
1.2 KiB
Go
Raw Normal View History

2023-02-02 19:40:54 +08:00
package localcache
import (
2023-02-23 19:15:30 +08:00
"OpenIM/pkg/common/config"
"OpenIM/pkg/discoveryregistry"
"OpenIM/pkg/proto/conversation"
2023-02-02 19:40:54 +08:00
"context"
"sync"
)
2023-02-08 17:56:04 +08:00
type ConversationLocalCacheInterface interface {
2023-02-09 14:40:49 +08:00
GetRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) ([]string, error)
2023-02-08 17:56:04 +08:00
}
2023-02-02 19:40:54 +08:00
type ConversationLocalCache struct {
lock sync.Mutex
SuperGroupRecvMsgNotNotifyUserIDs map[string][]string
2023-02-23 17:28:57 +08:00
client discoveryregistry.SvcDiscoveryRegistry
2023-02-02 19:40:54 +08:00
}
2023-03-03 17:42:26 +08:00
func NewConversationLocalCache(client discoveryregistry.SvcDiscoveryRegistry) *ConversationLocalCache {
return &ConversationLocalCache{
2023-02-02 19:40:54 +08:00
SuperGroupRecvMsgNotNotifyUserIDs: make(map[string][]string, 0),
2023-02-08 18:29:11 +08:00
client: client,
2023-02-02 19:40:54 +08:00
}
}
2023-02-09 14:40:49 +08:00
func (g *ConversationLocalCache) GetRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) ([]string, error) {
2023-02-23 17:28:57 +08:00
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
2023-02-02 19:40:54 +08:00
}