mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-11-20 07:53:34 +08:00
fix(core): derive possible real IDs from notification conversation IDs
Use the shared helper to resolve candidate conversation IDs and validate ownership.
This commit is contained in:
parent
11309b2917
commit
6d80f5500c
@ -155,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