fix: harden group lifecycle and registration writes

This commit is contained in:
richjohnrambo
2026-09-14 12:04:10 +08:00
parent 990526647c
commit 4854e090ef
9 changed files with 182 additions and 28 deletions
+33
View File
@@ -1716,6 +1716,11 @@ func (groupBusinessMapper) UpdateSettings(tenantID types.TenantID, topic string,
} else {
_ = DeleteCachedObject(tenantID, cacheNamespaceGroupSettings, strings.TrimSpace(topic))
}
if patch.MuteAll != nil {
invalidateGroupMemberPages(tenantID, topic)
invalidateGroupMemberObjects(tenantID, topic)
invalidateTopicSubscriptions(tenantID, topic)
}
}
return settings, err
}
@@ -1735,6 +1740,9 @@ func (groupBusinessMapper) Dissolve(tenantID types.TenantID, topic string, actor
} else {
_ = DeleteCachedObject(tenantID, cacheNamespaceGroupSettings, strings.TrimSpace(topic))
}
invalidateGroupMemberPages(tenantID, topic)
invalidateGroupMemberObjects(tenantID, topic)
invalidateTopicSubscriptions(tenantID, topic)
}
return settings, err
}
@@ -1825,6 +1833,31 @@ func invalidateGroupMemberPages(tenantID types.TenantID, topic string) {
}
}
func invalidateGroupMemberObjects(tenantID types.TenantID, topic string) {
topic = strings.TrimSpace(topic)
if topic == "" {
return
}
if err := DeleteCachedObjectsByPrefix(tenantID, cacheNamespaceGroupMember, topic+":"); err != nil {
logs.Warn.Printf("cache group members[%s]: delete failed: %v", topic, err)
}
}
func invalidateTopicSubscriptions(tenantID types.TenantID, topic string) {
topic = strings.TrimSpace(topic)
if topic == "" {
return
}
if err := DeleteCachedObjectsByPrefix(tenantID, cacheNamespaceSub, topic+":"); err != nil {
logs.Warn.Printf("cache subscriptions[%s]: delete failed: %v", topic, err)
}
if channel := types.GrpToChn(topic); channel != topic {
if err := DeleteCachedObjectsByPrefix(tenantID, cacheNamespaceSub, channel+":"); err != nil {
logs.Warn.Printf("cache subscriptions[%s]: delete failed: %v", channel, err)
}
}
}
func (groupBusinessMapper) UpdateMember(tenantID types.TenantID, topic string, uid types.Uid, patch types.GroupMemberPatch) (*types.GroupMember, error) {
if strings.TrimSpace(topic) == "" || uid.IsZero() {
return nil, types.ErrMalformed