diff options
| author | 2023-04-10 11:30:00 +0200 | |
|---|---|---|
| committer | 2023-04-10 11:30:00 +0200 | |
| commit | 862dafd066b2276550f7125692a6564a6f141339 (patch) | |
| tree | 2e45771330305e87af7ac6f7aa39be07225a206c | |
| parent | More mastoapi timeline work. (diff) | |
| download | snac2-862dafd066b2276550f7125692a6564a6f141339.tar.gz snac2-862dafd066b2276550f7125692a6564a6f141339.tar.xz snac2-862dafd066b2276550f7125692a6564a6f141339.zip | |
Some timeline fixes.
| -rw-r--r-- | mastoapi.c | 17 |
1 files changed, 13 insertions, 4 deletions
| @@ -443,12 +443,15 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 443 | const char *since_id = xs_dict_get(args, "since_id"); | 443 | const char *since_id = xs_dict_get(args, "since_id"); |
| 444 | // const char *min_id = xs_dict_get(args, "min_id"); | 444 | // const char *min_id = xs_dict_get(args, "min_id"); |
| 445 | const char *limit_s = xs_dict_get(args, "limit"); | 445 | const char *limit_s = xs_dict_get(args, "limit"); |
| 446 | int limit = 20; | 446 | int limit = 0; |
| 447 | int cnt = 0; | 447 | int cnt = 0; |
| 448 | 448 | ||
| 449 | if (!xs_is_null(limit_s)) | 449 | if (!xs_is_null(limit_s)) |
| 450 | limit = atoi(limit_s); | 450 | limit = atoi(limit_s); |
| 451 | 451 | ||
| 452 | if (limit == 0) | ||
| 453 | limit = 20; | ||
| 454 | |||
| 452 | xs *timeline = timeline_simple_list(&snac, "private", 0, XS_ALL); | 455 | xs *timeline = timeline_simple_list(&snac, "private", 0, XS_ALL); |
| 453 | 456 | ||
| 454 | xs *out = xs_list_new(); | 457 | xs *out = xs_list_new(); |
| @@ -495,13 +498,17 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 495 | if (xs_is_null(display_name) || *display_name == '\0') | 498 | if (xs_is_null(display_name) || *display_name == '\0') |
| 496 | display_name = xs_dict_get(actor, "preferredUsername"); | 499 | display_name = xs_dict_get(actor, "preferredUsername"); |
| 497 | 500 | ||
| 498 | const char *id = xs_dict_get(actor, "id"); | 501 | const char *id = xs_dict_get(actor, "id"); |
| 502 | const char *pub = xs_dict_get(actor, "published"); | ||
| 499 | xs *acct_md5 = xs_md5_hex(id, strlen(id)); | 503 | xs *acct_md5 = xs_md5_hex(id, strlen(id)); |
| 500 | acct = xs_dict_append(acct, "id", acct_md5); | 504 | acct = xs_dict_append(acct, "id", acct_md5); |
| 501 | acct = xs_dict_append(acct, "username", xs_dict_get(actor, "preferredUsername")); | 505 | acct = xs_dict_append(acct, "username", xs_dict_get(actor, "preferredUsername")); |
| 502 | acct = xs_dict_append(acct, "acct", xs_dict_get(actor, "preferredUsername")); | 506 | acct = xs_dict_append(acct, "acct", xs_dict_get(actor, "preferredUsername")); |
| 503 | acct = xs_dict_append(acct, "display_name", display_name); | 507 | acct = xs_dict_append(acct, "display_name", display_name); |
| 504 | acct = xs_dict_append(acct, "created_at", xs_dict_get(actor, "published")); | 508 | |
| 509 | if (pub) | ||
| 510 | acct = xs_dict_append(acct, "created_at", pub); | ||
| 511 | |||
| 505 | acct = xs_dict_append(acct, "note", xs_dict_get(actor, "summary")); | 512 | acct = xs_dict_append(acct, "note", xs_dict_get(actor, "summary")); |
| 506 | acct = xs_dict_append(acct, "url", id); | 513 | acct = xs_dict_append(acct, "url", id); |
| 507 | 514 | ||
| @@ -624,6 +631,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 624 | *body = xs_json_dumps_pp(out, 4); | 631 | *body = xs_json_dumps_pp(out, 4); |
| 625 | *ctype = "application/json"; | 632 | *ctype = "application/json"; |
| 626 | status = 200; | 633 | status = 200; |
| 634 | |||
| 635 | // printf("%s\n", *body); | ||
| 627 | } | 636 | } |
| 628 | else { | 637 | else { |
| 629 | status = 401; // unauthorized | 638 | status = 401; // unauthorized |