summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 08941cf..86cf334 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -705,12 +705,47 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
705 if (strcmp(cmd, "/v1/accounts/relationships") == 0) { 705 if (strcmp(cmd, "/v1/accounts/relationships") == 0) {
706 /* find if an account is followed, blocked, etc. */ 706 /* find if an account is followed, blocked, etc. */
707 /* the account to get relationships about is in args "id[]" */ 707 /* the account to get relationships about is in args "id[]" */
708 /* dummy by now */ 708
709 if (logged_in) { 709 if (logged_in) {
710 *body = xs_dup("[]"); 710 xs *res = xs_list_new();
711 const char *md5 = xs_dict_get(args, "id[]");
712 xs *actor_o = NULL;
713
714 if (!xs_is_null(md5) && valid_status(object_get_by_md5(md5, &actor_o))) {
715 xs *rel = xs_dict_new();
716 xs *t = xs_val_new(XSTYPE_TRUE);
717 xs *f = xs_val_new(XSTYPE_FALSE);
718
719 const char *actor = xs_dict_get(actor_o, "id");
720
721 rel = xs_dict_append(rel, "id", md5);
722 rel = xs_dict_append(rel, "following",
723 following_check(&snac1, actor) ? t : f);
724
725 rel = xs_dict_append(rel, "showing_reblogs", t);
726 rel = xs_dict_append(rel, "notifying", f);
727 rel = xs_dict_append(rel, "followed_by",
728 follower_check(&snac1, actor) ? t : f);
729
730 rel = xs_dict_append(rel, "blocking",
731 is_muted(&snac1, actor) ? t : f);
732
733 rel = xs_dict_append(rel, "muting", f);
734 rel = xs_dict_append(rel, "muting_notifications", f);
735 rel = xs_dict_append(rel, "requested", f);
736 rel = xs_dict_append(rel, "domain_blocking", f);
737 rel = xs_dict_append(rel, "endorsed", f);
738 rel = xs_dict_append(rel, "note", "");
739
740 res = xs_list_append(res, rel);
741 }
742
743 *body = xs_json_dumps_pp(res, 4);
711 *ctype = "application/json"; 744 *ctype = "application/json";
712 status = 200; 745 status = 200;
713 } 746 }
747 else
748 status = 422;
714 } 749 }
715 else 750 else
716 if (xs_startswith(cmd, "/v1/accounts/")) { 751 if (xs_startswith(cmd, "/v1/accounts/")) {