Files

23 lines
603 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package presence
// EncodeGetData 把 Get 结果编成 presence.get 的 resp data(items 数组)。
// 未知编号项为 {"id":"...","not_found":true},其余含 id/online/since_ms。
func EncodeGetData(items []StatusItem) map[string]any {
out := make([]map[string]any, 0, len(items))
for _, it := range items {
if it.NotFound {
out = append(out, map[string]any{
"id": it.ID,
"not_found": true,
})
continue
}
out = append(out, map[string]any{
"id": it.ID,
"online": it.Online,
"since_ms": it.SinceMs,
})
}
return map[string]any{"items": out}
}