mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-11-24 02:24:59 +08:00
fix(core): derive possible real IDs from notification conversation IDs
This commit is contained in:
parent
dc25996c48
commit
3ecb9adf9a
@ -16,6 +16,10 @@ package rpccache
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/cachekey"
|
||||
@ -26,8 +30,6 @@ import (
|
||||
"github.com/openimsdk/tools/errs"
|
||||
"github.com/openimsdk/tools/log"
|
||||
"github.com/openimsdk/tools/utils/datautil"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -153,20 +155,11 @@ func (c *ConversationLocalCache) CheckConversationAccess(ctx context.Context, us
|
||||
}
|
||||
candidateSet := make(map[string]struct{}, len(pending))
|
||||
for conversationID := range pending {
|
||||
if conversationutil.IsNotificationConversationID(conversationID) {
|
||||
suffix := conversationID[2:]
|
||||
candidateSet["si_"+suffix] = struct{}{}
|
||||
candidateSet["sn_"+suffix] = struct{}{}
|
||||
candidateSet["g_"+suffix] = struct{}{}
|
||||
candidateSet[conversationutil.GenGroupConversationID(suffix)] = struct{}{}
|
||||
} else {
|
||||
candidateSet[conversationID] = struct{}{}
|
||||
for _, rid := range conversationutil.GetPossibleRealConversationIDs(conversationID) {
|
||||
candidateSet[rid] = struct{}{}
|
||||
}
|
||||
}
|
||||
candidates := make([]string, 0, len(candidateSet))
|
||||
for conversationID := range candidateSet {
|
||||
candidates = append(candidates, conversationID)
|
||||
}
|
||||
candidates := datautil.Keys(candidateSet)
|
||||
owned, err := c.GetConversations(ctx, userID, candidates)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -52,3 +52,16 @@ func GetSeqsBeginEnd(seqs []int64) (int64, int64) {
|
||||
}
|
||||
return seqs[0], seqs[len(seqs)-1]
|
||||
}
|
||||
|
||||
func GetPossibleRealConversationIDs(conversationID string) []string {
|
||||
if !IsNotificationConversationID(conversationID) {
|
||||
return []string{conversationID}
|
||||
}
|
||||
suffix := strings.TrimPrefix(conversationID, "n_")
|
||||
return []string{
|
||||
"si_" + suffix,
|
||||
"sn_" + suffix,
|
||||
"g_" + suffix,
|
||||
"sg_" + suffix,
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user