From e6baeadf5fed47877ed3362a158308a5783d7155 Mon Sep 17 00:00:00 2001 From: default Date: Tue, 25 Jul 2023 12:01:42 +0200 Subject: Allow the 'attachment' field of a post to be single object instead of a list. It seems that Gotosocial does this. --- html.c | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'html.c') diff --git a/html.c b/html.c index ec5effa..3e77b84 100644 --- a/html.c +++ b/html.c @@ -1153,16 +1153,31 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local, s = xs_str_cat(s, "\n"); /* add the attachments */ - xs_list *attach = xs_dict_get(msg, "attachment"); - xs_dict *image = xs_dict_get(msg, "image"); + v = xs_dict_get(msg, "attachment"); - if (!xs_is_null(attach) || !xs_is_null(image)) { /** **/ - char *v; + if (!xs_is_null(v)) { /** attachments **/ + xs *attach = NULL; + + /* ensure it's a list */ + if (xs_type(v) == XSTYPE_DICT) { + attach = xs_list_new(); + attach = xs_list_append(attach, v); + } + else + attach = xs_dup(v); + + /* does the message have an image? */ + if (xs_type(v = xs_dict_get(msg, "image")) == XSTYPE_DICT) { + /* add it to the attachment list */ + attach = xs_list_append(attach, v); + } /* make custom css for attachments easier */ s = xs_str_cat(s, "
\n"); } -- cgit v1.2.3