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

Method NormalizeAssets

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

Source from the content-addressed store, hash-verified

143}
144
145func (n Normalizer) NormalizeAssets(payload any) []Asset {
146 items, ok := payload.([]any)
147 if !ok {
148 return nil
149 }
150
151 out := make([]Asset, 0, len(items))
152 seenLinks := make(map[string]struct{})
153 for _, item := range items {
154 m, ok := item.(map[string]any)
155 if !ok {
156 continue
157 }
158
159 link, _ := m["link"].(string)
160 link = strings.TrimSpace(link)
161 if link == "" {
162 continue
163 }
164 if _, ok := seenLinks[link]; ok {
165 continue
166 }
167 seenLinks[link] = struct{}{}
168
169 asset := Asset{Link: link}
170 if name, ok := nonEmptyString(m["name"]); ok {
171 asset.Name = &name
172 }
173 if image, ok := nonEmptyString(m["image"]); ok {
174 asset.Image = &image
175 }
176 out = append(out, asset)
177 }
178
179 return out
180}
181
182func (n Normalizer) NormalizeDeadline(payload any) StoredDeadline {
183 switch v := payload.(type) {

Callers 1

LoadLegacySnapshotFunction · 0.80

Calls 1

nonEmptyStringFunction · 0.85

Tested by

no test coverage detected