diff options
| author | default <nobody@localhost> | 2024-11-23 17:08:57 +0100 |
|---|---|---|
| committer | default <nobody@localhost> | 2024-11-23 17:08:57 +0100 |
| commit | 09d268495c12d3c00a7293fbf445830bcc9d74c3 (patch) | |
| tree | 6a0f3838336ecc8679bedc78ff713c76ec4ef5c8 /activitypub.c | |
| parent | 775fb14706d92af9106b2ac0b87b4c4bd1f5b3ca (diff) | |
The 'metadata' field in user.json is now a string instead of a dict.
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/activitypub.c b/activitypub.c index 473675d..8c0c423 100644 --- a/activitypub.c +++ b/activitypub.c @@ -1218,7 +1218,30 @@ xs_dict *msg_actor(snac *snac) } /* add the metadata as attachments of PropertyValue */ - const xs_dict *metadata = xs_dict_get(snac->config, "metadata"); + xs *metadata = NULL; + const xs_dict *md = xs_dict_get(snac->config, "metadata"); + + if (xs_type(md) == XSTYPE_DICT) + metadata = xs_dup(md); + else + if (xs_type(md) == XSTYPE_STRING) { + metadata = xs_dict_new(); + xs *l = xs_split(md, "\r\n"); + const char *ll; + + xs_list_foreach(l, ll) { + xs *kv = xs_split_n(ll, "=", 1); + const char *k = xs_list_get(kv, 0); + const char *v = xs_list_get(kv, 1); + + if (k && v) { + xs *kk = xs_strip_i(xs_dup(k)); + xs *vv = xs_strip_i(xs_dup(v)); + metadata = xs_dict_set(metadata, kk, vv); + } + } + } + if (xs_type(metadata) == XSTYPE_DICT) { xs *attach = xs_list_new(); const xs_str *k; |