commit c4b2d3b

default  ·  2023-09-18 09:24:30 +0000 UTC
parent 5a3c7cf
If an account has metadata, return them as attachment PropertyValues in msg_actor().
1 files changed,  +20, -0
+20, -0
 1@@ -972,6 +972,26 @@ xs_dict *msg_actor(snac *snac)
 2         msg = xs_dict_set(msg, "image", d);
 3     }
 4 
 5+    /* add the metadata as attachments of PropertyValue */
 6+    xs_dict *metadata = xs_dict_get(snac->config, "metadata");
 7+    if (xs_type(metadata) == XSTYPE_DICT) {
 8+        xs *attach = xs_list_new();
 9+        xs_str *k;
10+        xs_str *v;
11+
12+        while (xs_dict_iter(&metadata, &k, &v)) {
13+            xs *d = xs_dict_new();
14+
15+            d = xs_dict_append(d, "type",  "PropertyValue");
16+            d = xs_dict_append(d, "name",  k);
17+            d = xs_dict_append(d, "value", v);
18+
19+            attach = xs_list_append(attach, d);
20+        }
21+
22+        msg = xs_dict_set(msg, "attachment", attach);
23+    }
24+
25     return msg;
26 }
27