summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-04-11 11:00:06 +0200
committerGravatar default2023-04-11 11:00:06 +0200
commita4051f7f3774ac6a1e25ebb81a13c455e735b862 (patch)
tree1c9da223fb1ce9aff9b61c29381fc34d741381ed
parentNew function mastodon_status(). (diff)
downloadpenes-snac2-a4051f7f3774ac6a1e25ebb81a13c455e735b862.tar.gz
penes-snac2-a4051f7f3774ac6a1e25ebb81a13c455e735b862.tar.xz
penes-snac2-a4051f7f3774ac6a1e25ebb81a13c455e735b862.zip
Started work in /api/v1/statuses.
-rw-r--r--mastoapi.c46
1 files changed, 44 insertions, 2 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 791d3b8..3550264 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -603,10 +603,10 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
603 return 0; 603 return 0;
604 604
605 srv_debug(0, xs_fmt("mastoapi_get_handler %s", q_path)); 605 srv_debug(0, xs_fmt("mastoapi_get_handler %s", q_path));
606 { 606/* {
607 xs *j = xs_json_dumps_pp(req, 4); 607 xs *j = xs_json_dumps_pp(req, 4);
608 printf("mastoapi get:\n%s\n", j); 608 printf("mastoapi get:\n%s\n", j);
609 } 609 }*/
610 610
611 int status = 404; 611 int status = 404;
612 xs_dict *args = xs_dict_get(req, "q_vars"); 612 xs_dict *args = xs_dict_get(req, "q_vars");
@@ -772,6 +772,48 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
772 *ctype = "application/json"; 772 *ctype = "application/json";
773 status = 200; 773 status = 200;
774 } 774 }
775 else
776 if (xs_startswith(cmd, "/statuses/")) {
777 /* operations on a status */
778 xs *l = xs_split(cmd, "/");
779 const char *id = xs_list_get(l, 2);
780 const char *op = xs_list_get(l, 3);
781
782 if (!xs_is_null(id)) {
783 xs *msg = NULL;
784 xs *out = NULL;
785
786 /* skip the fake part of the id (the date) */
787 id += 14;
788
789 if (valid_status(timeline_get_by_md5(&snac, id, &msg))) {
790 if (op == NULL) {
791 /* return the status itself */
792 }
793 else
794 if (strcmp(op, "context") == 0) {
795 /* return ancestors and children */
796 srv_debug(0, xs_fmt("mastoapi status: context requested for %s", id));
797 }
798 else
799 if (strcmp(op, "reblogged_by") == 0) {
800 /* return the list of boosts */
801 }
802 else
803 if (strcmp(op, "favourited_by") == 0) {
804 /* return the list of likes */
805 }
806 }
807 else
808 srv_debug(0, xs_fmt("mastoapi status: bad id %s", id));
809
810 if (out != NULL) {
811 *body = xs_json_dumps_pp(out, 4);
812 *ctype = "application/json";
813 status = 200;
814 }
815 }
816 }
775 817
776 /* user cleanup */ 818 /* user cleanup */
777 if (logged_in) 819 if (logged_in)