summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authorGravatar default2024-04-29 10:15:04 +0200
committerGravatar default2024-04-29 10:15:04 +0200
commitf1221808a858b0d205f3acdb028d58d362ef22e6 (patch)
treeafa34b04e1b66266744b46054f86f3432b5bb1a3 /mastoapi.c
parentNew function list_distribute(). (diff)
downloadpenes-snac2-f1221808a858b0d205f3acdb028d58d362ef22e6.tar.gz
penes-snac2-f1221808a858b0d205f3acdb028d58d362ef22e6.tar.xz
penes-snac2-f1221808a858b0d205f3acdb028d58d362ef22e6.zip
More work in lists.
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 8c41efb..6316951 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -1647,6 +1647,77 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1647 status = 200; 1647 status = 200;
1648 } 1648 }
1649 else 1649 else
1650 if (xs_startswith(cmd, "/v1/timelines/list/")) { /** **/
1651 /* get the list id */
1652 if (logged_in) {
1653 xs *l = xs_split(cmd, "/");
1654 char *list = xs_list_get(l, -1);
1655
1656 xs *timeline = list_content(&snac1, list, NULL, 3);
1657 xs *out = xs_list_new();
1658 int c = 0;
1659 char *md5;
1660
1661 while (xs_list_next(timeline, &md5, &c)) {
1662 xs *msg = NULL;
1663
1664 /* get the entry */
1665 if (!valid_status(timeline_get_by_md5(&snac1, md5, &msg)))
1666 continue;
1667
1668 /* discard non-Notes */
1669 const char *id = xs_dict_get(msg, "id");
1670 const char *type = xs_dict_get(msg, "type");
1671 if (!xs_match(type, "Note|Question|Page|Article|Video"))
1672 continue;
1673
1674 const char *from = NULL;
1675 if (strcmp(type, "Page") == 0)
1676 from = xs_dict_get(msg, "audience");
1677
1678 if (from == NULL)
1679 from = get_atto(msg);
1680
1681 if (from == NULL)
1682 continue;
1683
1684 /* is this message from a person we don't follow? */
1685 if (strcmp(from, snac1.actor) && !following_check(&snac1, from)) {
1686 /* discard if it was not boosted */
1687 xs *idx = object_announces(id);
1688
1689 if (xs_list_len(idx) == 0)
1690 continue;
1691 }
1692
1693 /* discard notes from muted morons */
1694 if (is_muted(&snac1, from))
1695 continue;
1696
1697 /* discard hidden notes */
1698 if (is_hidden(&snac1, id))
1699 continue;
1700
1701 /* if it has a name and it's not a Page or a Video,
1702 it's a poll vote, so discard it */
1703 if (!xs_is_null(xs_dict_get(msg, "name")) && !xs_match(type, "Page|Video"))
1704 continue;
1705
1706 /* convert the Note into a Mastodon status */
1707 xs *st = mastoapi_status(&snac1, msg);
1708
1709 if (st != NULL)
1710 out = xs_list_append(out, st);
1711 }
1712
1713 *body = xs_json_dumps(out, 4);
1714 *ctype = "application/json";
1715 status = 200;
1716 }
1717 else
1718 status = 421;
1719 }
1720 else
1650 if (strcmp(cmd, "/v1/conversations") == 0) { /** **/ 1721 if (strcmp(cmd, "/v1/conversations") == 0) { /** **/
1651 /* TBD */ 1722 /* TBD */
1652 *body = xs_dup("[]"); 1723 *body = xs_dup("[]");