MCPcopy Create free account
hub / github.com/MMadmer/EpicAssetsNotifyBot / NormalizeUserProfiles

Method NormalizeUserProfiles

internal/model/normalize.go:107–143  ·  view source on GitHub ↗
(payload any)

Source from the content-addressed store, hash-verified

105}
106
107func (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
145func (n Normalizer) NormalizeAssets(payload any) []Asset {
146 items, ok := payload.([]any)

Callers 1

LoadLegacySnapshotFunction · 0.80

Calls 4

asInt64Function · 0.85
asBoolFunction · 0.85
asBoolDefaultFunction · 0.85

Tested by

no test coverage detected