diff options
| -rw-r--r-- | mastoapi.c | 41 |
1 files changed, 41 insertions, 0 deletions
| @@ -1533,6 +1533,47 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1533 | status = 200; | 1533 | status = 200; |
| 1534 | } | 1534 | } |
| 1535 | else | 1535 | else |
| 1536 | if (xs_startswith(cmd, "/v1/timelines/tag/")) { /** **/ | ||
| 1537 | const char *limit_s = xs_dict_get(args, "limit"); | ||
| 1538 | int limit = 0; | ||
| 1539 | int cnt = 0; | ||
| 1540 | |||
| 1541 | if (!xs_is_null(limit_s)) | ||
| 1542 | limit = atoi(limit_s); | ||
| 1543 | |||
| 1544 | if (limit == 0) | ||
| 1545 | limit = 20; | ||
| 1546 | |||
| 1547 | /* get the tag */ | ||
| 1548 | xs *l = xs_split(cmd, "/"); | ||
| 1549 | char *tag = xs_list_get(l, -1); | ||
| 1550 | |||
| 1551 | xs *timeline = tag_search(tag, 0, limit); | ||
| 1552 | xs *out = xs_list_new(); | ||
| 1553 | xs_list *p = timeline; | ||
| 1554 | xs_str *md5; | ||
| 1555 | |||
| 1556 | while (xs_list_iter(&p, &md5) && cnt < limit) { | ||
| 1557 | xs *msg = NULL; | ||
| 1558 | |||
| 1559 | /* get the entry */ | ||
| 1560 | if (!valid_status(object_get_by_md5(md5, &msg))) | ||
| 1561 | continue; | ||
| 1562 | |||
| 1563 | /* convert the Note into a Mastodon status */ | ||
| 1564 | xs *st = mastoapi_status(NULL, msg); | ||
| 1565 | |||
| 1566 | if (st != NULL) { | ||
| 1567 | out = xs_list_append(out, st); | ||
| 1568 | cnt++; | ||
| 1569 | } | ||
| 1570 | } | ||
| 1571 | |||
| 1572 | *body = xs_json_dumps(out, 4); | ||
| 1573 | *ctype = "application/json"; | ||
| 1574 | status = 200; | ||
| 1575 | } | ||
| 1576 | else | ||
| 1536 | if (strcmp(cmd, "/v1/conversations") == 0) { /** **/ | 1577 | if (strcmp(cmd, "/v1/conversations") == 0) { /** **/ |
| 1537 | /* TBD */ | 1578 | /* TBD */ |
| 1538 | *body = xs_dup("[]"); | 1579 | *body = xs_dup("[]"); |