Add youth mode restriction labels
This commit is contained in:
+48
-6
@@ -8166,12 +8166,13 @@ func appReleasePayload(release *types.AppRelease) map[string]any {
|
||||
|
||||
func youthModePayload(settings *types.YouthModeSettings) map[string]any {
|
||||
data := map[string]any{
|
||||
"enabled": settings.Enabled,
|
||||
"policy_version": settings.PolicyVersion,
|
||||
"restrictions": settings.Restrictions,
|
||||
"password_set": settings.PasswordSet,
|
||||
"can_enable": settings.CanEnable,
|
||||
"updated_at": settings.UpdatedAt.UTC().Format(time.RFC3339Nano),
|
||||
"enabled": settings.Enabled,
|
||||
"policy_version": settings.PolicyVersion,
|
||||
"restrictions": settings.Restrictions,
|
||||
"restriction_items": youthModeRestrictionItems(settings.Restrictions),
|
||||
"password_set": settings.PasswordSet,
|
||||
"can_enable": settings.CanEnable,
|
||||
"updated_at": settings.UpdatedAt.UTC().Format(time.RFC3339Nano),
|
||||
}
|
||||
if settings.EnabledAt != nil {
|
||||
data["enabled_at"] = settings.EnabledAt.UTC().Format(time.RFC3339Nano)
|
||||
@@ -8179,6 +8180,47 @@ func youthModePayload(settings *types.YouthModeSettings) map[string]any {
|
||||
return data
|
||||
}
|
||||
|
||||
func youthModeRestrictionItems(restrictions []string) []map[string]any {
|
||||
catalog := map[string]map[string]any{
|
||||
"night_quiet": {
|
||||
"code": "night_quiet",
|
||||
"title": "深夜免打扰",
|
||||
"description": "夜间减少消息提醒打扰,帮助用户保持健康作息。",
|
||||
"enforced": false,
|
||||
},
|
||||
"content_filter": {
|
||||
"code": "content_filter",
|
||||
"title": "内容过滤",
|
||||
"description": "对不适合青少年的内容进行识别和限制展示。",
|
||||
"enforced": false,
|
||||
},
|
||||
"payment_guard": {
|
||||
"code": "payment_guard",
|
||||
"title": "支付守护",
|
||||
"description": "限制或确认支付、充值等敏感消费行为。",
|
||||
"enforced": false,
|
||||
},
|
||||
}
|
||||
items := make([]map[string]any, 0, len(restrictions))
|
||||
for _, code := range restrictions {
|
||||
code = strings.TrimSpace(code)
|
||||
if code == "" {
|
||||
continue
|
||||
}
|
||||
if item, ok := catalog[code]; ok {
|
||||
items = append(items, item)
|
||||
continue
|
||||
}
|
||||
items = append(items, map[string]any{
|
||||
"code": code,
|
||||
"title": code,
|
||||
"description": "",
|
||||
"enforced": false,
|
||||
})
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
func devicePushTokenPayload(token *types.DevicePushToken) map[string]any {
|
||||
return map[string]any{
|
||||
"device_id": token.DeviceID,
|
||||
|
||||
Reference in New Issue
Block a user