From dd4ba7969f5e48544ab2e1833c353ef9830733c5 Mon Sep 17 00:00:00 2001 From: default Date: Wed, 26 Apr 2023 21:07:00 +0200 Subject: [PATCH] Fixed video attachments. --- mastoapi.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/mastoapi.c b/mastoapi.c index d7bc8c1..18028cd 100644 --- a/mastoapi.c +++ b/mastoapi.c @@ -570,23 +570,25 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg) while (xs_list_iter(&att, &aobj)) { const char *mtype = xs_dict_get(aobj, "mediaType"); - if (!xs_is_null(mtype) && xs_startswith(mtype, "image/")) { - xs *matteid = xs_fmt("%s_%d", id, xs_list_len(matt)); - xs *matte = xs_dict_new(); + if (!xs_is_null(mtype)) { + if (xs_startswith(mtype, "image/") || xs_startswith(mtype, "video/")) { + xs *matteid = xs_fmt("%s_%d", id, xs_list_len(matt)); + xs *matte = xs_dict_new(); - matte = xs_dict_append(matte, "id", matteid); - matte = xs_dict_append(matte, "type", "image"); - matte = xs_dict_append(matte, "url", xs_dict_get(aobj, "url")); - matte = xs_dict_append(matte, "preview_url", xs_dict_get(aobj, "url")); - matte = xs_dict_append(matte, "remote_url", xs_dict_get(aobj, "url")); + matte = xs_dict_append(matte, "id", matteid); + matte = xs_dict_append(matte, "type", *mtype == 'i' ? "image" : "video"); + matte = xs_dict_append(matte, "url", xs_dict_get(aobj, "url")); + matte = xs_dict_append(matte, "preview_url", xs_dict_get(aobj, "url")); + matte = xs_dict_append(matte, "remote_url", xs_dict_get(aobj, "url")); - const char *name = xs_dict_get(aobj, "name"); - if (xs_is_null(name)) - name = ""; + const char *name = xs_dict_get(aobj, "name"); + if (xs_is_null(name)) + name = ""; - matte = xs_dict_append(matte, "description", name); + matte = xs_dict_append(matte, "description", name); - matt = xs_list_append(matt, matte); + matt = xs_list_append(matt, matte); + } } }