summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authorGravatar default2023-04-12 10:41:15 +0200
committerGravatar default2023-04-12 10:41:15 +0200
commit885031bed9e54876fb262921b11df23aa00cedb6 (patch)
treea1541acecaa547b5a637600d76e8a0df1fde6225 /mastoapi.c
parentUse the ctime instead of the published date in mastoapi_id(). (diff)
downloadsnac2-885031bed9e54876fb262921b11df23aa00cedb6.tar.gz
snac2-885031bed9e54876fb262921b11df23aa00cedb6.tar.xz
snac2-885031bed9e54876fb262921b11df23aa00cedb6.zip
Don't generate invalid JSON if an attachment has no description.
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/mastoapi.c b/mastoapi.c
index be1ba61..3cfaa34 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -506,7 +506,12 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
506 matte = xs_dict_append(matte, "url", xs_dict_get(aobj, "url")); 506 matte = xs_dict_append(matte, "url", xs_dict_get(aobj, "url"));
507 matte = xs_dict_append(matte, "preview_url", xs_dict_get(aobj, "url")); 507 matte = xs_dict_append(matte, "preview_url", xs_dict_get(aobj, "url"));
508 matte = xs_dict_append(matte, "remote_url", xs_dict_get(aobj, "url")); 508 matte = xs_dict_append(matte, "remote_url", xs_dict_get(aobj, "url"));
509 matte = xs_dict_append(matte, "description", xs_dict_get(aobj, "name")); 509
510 const char *name = xs_dict_get(aobj, "name");
511 if (xs_is_null(name))
512 name = "";
513
514 matte = xs_dict_append(matte, "description", name);
510 515
511 matt = xs_list_append(matt, matte); 516 matt = xs_list_append(matt, matte);
512 } 517 }
@@ -730,6 +735,14 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
730 *ctype = "application/json"; 735 *ctype = "application/json";
731 status = 200; 736 status = 200;
732 737
738 {
739 xs *j = xs_json_loads(*body);
740 if (j == NULL) {
741 srv_debug(0, xs_fmt("mastoapi timeline: bad JSON"));
742 srv_archive_error("mastoapi_timeline", "bad JSON", req, *body);
743 }
744 }
745
733 srv_debug(0, xs_fmt("mastoapi timeline: returned %d entries", xs_list_len(out))); 746 srv_debug(0, xs_fmt("mastoapi timeline: returned %d entries", xs_list_len(out)));
734 } 747 }
735 else { 748 else {