fix: sync contact phone privacy disclosure
This commit is contained in:
parent
0e2fcdf9c8
commit
e1a95c7318
19 changed files with 789 additions and 50 deletions
|
|
@ -81,6 +81,31 @@ func (c *CachedPrivacyStore) SetPrivacyRules(ctx context.Context, rules domain.P
|
|||
return err
|
||||
}
|
||||
c.InvalidateOwners(rules.OwnerUserID)
|
||||
// 数据写入已提交,预热失败不能伪装成写失败;LISTEN/NOTIFY 也会在每个
|
||||
// 实例上再次失效并预热,覆盖本实例通知晚于这里到达的时序。
|
||||
_ = c.WarmOwners(ctx, rules.OwnerUserID)
|
||||
return nil
|
||||
}
|
||||
|
||||
// WarmOwners 在低频写/变更通知路径一次性装入 owner 的完整规则集。调用方必须先
|
||||
// InvalidateOwners;epoch 保证预热期间若又发生失效,不会把旧快照写回。
|
||||
func (c *CachedPrivacyStore) WarmOwners(ctx context.Context, ownerUserIDs ...int64) error {
|
||||
owners := dedupPrivacyOwnerIDs(ownerUserIDs)
|
||||
if len(owners) == 0 || c == nil || c.cache == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 隐私规则变更很少、读取极热。必须重建全部 key,
|
||||
// 不能只塞本次 key,否则会把 owner 的其它持久规则误当成默认规则。
|
||||
loadEpoch := c.cache.LoadEpoch()
|
||||
list, err := c.inner.ListPrivacyRules(ctx, owners, allPrivacyRuleKeys)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
snapshots := buildPrivacyRulesByOwner(list, owners)
|
||||
for _, ownerUserID := range owners {
|
||||
c.cache.StoreIfEpoch(ownerUserID, snapshots[ownerUserID], loadEpoch)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue