(payload any)
| 105 | } |
| 106 | |
| 107 | func (n Normalizer) NormalizeUserProfiles(payload any) []UserProfile { |
| 108 | items, ok := payload.([]any) |
| 109 | if !ok { |
| 110 | return nil |
| 111 | } |
| 112 | |
| 113 | seen := make(map[int64]UserProfile) |
| 114 | for _, item := range items { |
| 115 | m, ok := item.(map[string]any) |
| 116 | if !ok { |
| 117 | continue |
| 118 | } |
| 119 | |
| 120 | userID, ok := asInt64(m["id"]) |
| 121 | if !ok { |
| 122 | continue |
| 123 | } |
| 124 | |
| 125 | locale := n.normalizeLocaleFromAny(m["locale"]) |
| 126 | if locale == "" { |
| 127 | locale = n.baseLocale |
| 128 | } |
| 129 | |
| 130 | seen[userID] = UserProfile{ |
| 131 | ID: userID, |
| 132 | ShownAssets: asBool(m["shown_assets"]), |
| 133 | Locale: locale, |
| 134 | Subscribed: asBoolDefault(m["subscribed"], true), |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | out := make([]UserProfile, 0, len(seen)) |
| 139 | for _, v := range seen { |
| 140 | out = append(out, v) |
| 141 | } |
| 142 | return out |
| 143 | } |
| 144 | |
| 145 | func (n Normalizer) NormalizeAssets(payload any) []Asset { |
| 146 | items, ok := payload.([]any) |
no test coverage detected