commit dd4ba79

default  ·  2023-04-26 19:07:00 +0000 UTC
parent 9bb08cf
Fixed video attachments.
1 files changed,  +15, -13
+15, -13
 1@@ -570,23 +570,25 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
 2     while (xs_list_iter(&att, &aobj)) {
 3         const char *mtype = xs_dict_get(aobj, "mediaType");
 4 
 5-        if (!xs_is_null(mtype) && xs_startswith(mtype, "image/")) {
 6-            xs *matteid = xs_fmt("%s_%d", id, xs_list_len(matt));
 7-            xs *matte   = xs_dict_new();
 8+        if (!xs_is_null(mtype)) {
 9+            if (xs_startswith(mtype, "image/") || xs_startswith(mtype, "video/")) {
10+                xs *matteid = xs_fmt("%s_%d", id, xs_list_len(matt));
11+                xs *matte   = xs_dict_new();
12 
13-            matte = xs_dict_append(matte, "id",          matteid);
14-            matte = xs_dict_append(matte, "type",        "image");
15-            matte = xs_dict_append(matte, "url",         xs_dict_get(aobj, "url"));
16-            matte = xs_dict_append(matte, "preview_url", xs_dict_get(aobj, "url"));
17-            matte = xs_dict_append(matte, "remote_url",  xs_dict_get(aobj, "url"));
18+                matte = xs_dict_append(matte, "id",          matteid);
19+                matte = xs_dict_append(matte, "type",        *mtype == 'i' ? "image" : "video");
20+                matte = xs_dict_append(matte, "url",         xs_dict_get(aobj, "url"));
21+                matte = xs_dict_append(matte, "preview_url", xs_dict_get(aobj, "url"));
22+                matte = xs_dict_append(matte, "remote_url",  xs_dict_get(aobj, "url"));
23 
24-            const char *name = xs_dict_get(aobj, "name");
25-            if (xs_is_null(name))
26-                name = "";
27+                const char *name = xs_dict_get(aobj, "name");
28+                if (xs_is_null(name))
29+                    name = "";
30 
31-            matte = xs_dict_append(matte, "description", name);
32+                matte = xs_dict_append(matte, "description", name);
33 
34-            matt = xs_list_append(matt, matte);
35+                matt = xs_list_append(matt, matte);
36+            }
37         }
38     }
39