diff options
| author | 2023-12-03 10:05:04 +0100 | |
|---|---|---|
| committer | 2023-12-03 10:05:04 +0100 | |
| commit | f5bf8ef7e18ece180a59e0271e86da9f081407a7 (patch) | |
| tree | f107330042ac744179a37e677aaef096c644d0eb /mastoapi.c | |
| parent | mastoapi: return some dummy values in verify_credentials. (diff) | |
| download | snac2-f5bf8ef7e18ece180a59e0271e86da9f081407a7.tar.gz snac2-f5bf8ef7e18ece180a59e0271e86da9f081407a7.tar.xz snac2-f5bf8ef7e18ece180a59e0271e86da9f081407a7.zip | |
mastoapi: patched dates to match the funny timezone Mastodon uses.
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 31 |
1 files changed, 28 insertions, 3 deletions
| @@ -592,10 +592,27 @@ xs_dict *mastoapi_account(const xs_dict *actor) | |||
| 592 | acct = xs_dict_append(acct, "emojis", eml); | 592 | acct = xs_dict_append(acct, "emojis", eml); |
| 593 | } | 593 | } |
| 594 | 594 | ||
| 595 | acct = xs_dict_append(acct, "locked", xs_stock_false); | ||
| 596 | acct = xs_dict_append(acct, "followers_count", xs_stock_0); | ||
| 597 | acct = xs_dict_append(acct, "following_count", xs_stock_0); | ||
| 598 | acct = xs_dict_append(acct, "statuses_count", xs_stock_0); | ||
| 599 | |||
| 600 | acct = xs_dict_append(acct, "fields", xs_stock_list); | ||
| 601 | |||
| 595 | return acct; | 602 | return acct; |
| 596 | } | 603 | } |
| 597 | 604 | ||
| 598 | 605 | ||
| 606 | xs_str *mastoapi_date(char *date) | ||
| 607 | /* converts an ISO 8601 date to whatever format Mastodon uses */ | ||
| 608 | { | ||
| 609 | xs_str *s = xs_crop_i(xs_dup(date), 0, 19); | ||
| 610 | s = xs_str_cat(s, ".000Z"); | ||
| 611 | |||
| 612 | return s; | ||
| 613 | } | ||
| 614 | |||
| 615 | |||
| 599 | xs_dict *mastoapi_poll(snac *snac, const xs_dict *msg) | 616 | xs_dict *mastoapi_poll(snac *snac, const xs_dict *msg) |
| 600 | /* creates a mastoapi Poll object */ | 617 | /* creates a mastoapi Poll object */ |
| 601 | { | 618 | { |
| @@ -607,7 +624,8 @@ xs_dict *mastoapi_poll(snac *snac, const xs_dict *msg) | |||
| 607 | xs *options = xs_list_new(); | 624 | xs *options = xs_list_new(); |
| 608 | 625 | ||
| 609 | poll = xs_dict_append(poll, "id", mid); | 626 | poll = xs_dict_append(poll, "id", mid); |
| 610 | poll = xs_dict_append(poll, "expires_at", xs_dict_get(msg, "endTime")); | 627 | xs *fd = mastoapi_date(xs_dict_get(msg, "endTime")); |
| 628 | poll = xs_dict_append(poll, "expires_at", fd); | ||
| 611 | poll = xs_dict_append(poll, "expired", | 629 | poll = xs_dict_append(poll, "expired", |
| 612 | xs_dict_get(msg, "closed") != NULL ? xs_stock_true : xs_stock_false); | 630 | xs_dict_get(msg, "closed") != NULL ? xs_stock_true : xs_stock_false); |
| 613 | 631 | ||
| @@ -673,9 +691,11 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg) | |||
| 673 | st = xs_dict_append(st, "id", mid); | 691 | st = xs_dict_append(st, "id", mid); |
| 674 | st = xs_dict_append(st, "uri", id); | 692 | st = xs_dict_append(st, "uri", id); |
| 675 | st = xs_dict_append(st, "url", id); | 693 | st = xs_dict_append(st, "url", id); |
| 676 | st = xs_dict_append(st, "created_at", xs_dict_get(msg, "published")); | ||
| 677 | st = xs_dict_append(st, "account", acct); | 694 | st = xs_dict_append(st, "account", acct); |
| 678 | 695 | ||
| 696 | xs *fd = mastoapi_date(xs_dict_get(msg, "published")); | ||
| 697 | st = xs_dict_append(st, "created_at", fd); | ||
| 698 | |||
| 679 | { | 699 | { |
| 680 | const char *content = xs_dict_get(msg, "content"); | 700 | const char *content = xs_dict_get(msg, "content"); |
| 681 | const char *name = xs_dict_get(msg, "name"); | 701 | const char *name = xs_dict_get(msg, "name"); |
| @@ -928,10 +948,15 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg) | |||
| 928 | st = xs_dict_append(st, "text", tmp); | 948 | st = xs_dict_append(st, "text", tmp); |
| 929 | 949 | ||
| 930 | tmp = xs_dict_get(msg, "updated"); | 950 | tmp = xs_dict_get(msg, "updated"); |
| 951 | xs *fd2 = NULL; | ||
| 931 | if (xs_is_null(tmp)) | 952 | if (xs_is_null(tmp)) |
| 932 | tmp = xs_stock_null; | 953 | tmp = xs_stock_null; |
| 954 | else { | ||
| 955 | fd2 = mastoapi_date(tmp); | ||
| 956 | tmp = fd2; | ||
| 957 | } | ||
| 933 | 958 | ||
| 934 | st = xs_dict_append(st, "edited_at", tmp); | 959 | st = xs_dict_append(st, "edited_at", fd2); |
| 935 | 960 | ||
| 936 | if (strcmp(type, "Question") == 0) { | 961 | if (strcmp(type, "Question") == 0) { |
| 937 | xs *poll = mastoapi_poll(snac, msg); | 962 | xs *poll = mastoapi_poll(snac, msg); |