commit f1afe44
default
·
2023-12-03 09:57:54 +0000 UTC
parent f5bf8ef
Fill the 'fields' list in mastoapi_account().
1 files changed,
+22,
-1
+22,
-1
1@@ -597,7 +597,28 @@ xs_dict *mastoapi_account(const xs_dict *actor)
2 acct = xs_dict_append(acct, "following_count", xs_stock_0);
3 acct = xs_dict_append(acct, "statuses_count", xs_stock_0);
4
5- acct = xs_dict_append(acct, "fields", xs_stock_list);
6+ xs *fields = xs_list_new();
7+ p = xs_dict_get(actor, "attachment");
8+ xs_dict *v;
9+
10+ while (xs_list_iter(&p, &v)) {
11+ char *type = xs_dict_get(v, "type");
12+ char *name = xs_dict_get(v, "name");
13+ char *value = xs_dict_get(v, "value");
14+
15+ if (!xs_is_null(type) && !xs_is_null(name) &&
16+ !xs_is_null(value) && strcmp(type, "PropertyValue") == 0) {
17+ xs *d = xs_dict_new();
18+
19+ d = xs_dict_append(d, "name", name);
20+ d = xs_dict_append(d, "value", value);
21+ d = xs_dict_append(d, "verified_at", xs_stock_null);
22+
23+ fields = xs_list_append(fields, d);
24+ }
25+ }
26+
27+ acct = xs_dict_append(acct, "fields", fields);
28
29 return acct;
30 }