fix: harden group lifecycle and registration writes
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user