diff options
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 36 |
1 files changed, 27 insertions, 9 deletions
| @@ -2031,18 +2031,36 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 2031 | /* reply something only for offset 0; otherwise, | 2031 | /* reply something only for offset 0; otherwise, |
| 2032 | apps like Tusky keep asking again and again */ | 2032 | apps like Tusky keep asking again and again */ |
| 2033 | 2033 | ||
| 2034 | if (!xs_is_null(q) && !xs_is_null(type) && strcmp(type, "accounts") == 0) { | 2034 | if (!xs_is_null(q) && !xs_is_null(type)) { |
| 2035 | /* do a webfinger query */ | 2035 | if (strcmp(type, "accounts") == 0) { |
| 2036 | char *actor = NULL; | 2036 | /* do a webfinger query */ |
| 2037 | char *user = NULL; | 2037 | char *actor = NULL; |
| 2038 | char *user = NULL; | ||
| 2038 | 2039 | ||
| 2039 | if (valid_status(webfinger_request(q, &actor, &user)) && actor) { | 2040 | if (valid_status(webfinger_request(q, &actor, &user)) && actor) { |
| 2040 | xs *actor_o = NULL; | 2041 | xs *actor_o = NULL; |
| 2041 | 2042 | ||
| 2042 | if (valid_status(actor_request(&snac1, actor, &actor_o))) { | 2043 | if (valid_status(actor_request(&snac1, actor, &actor_o))) { |
| 2043 | xs *acct = mastoapi_account(actor_o); | 2044 | xs *acct = mastoapi_account(actor_o); |
| 2044 | 2045 | ||
| 2045 | acl = xs_list_append(acl, acct); | 2046 | acl = xs_list_append(acl, acct); |
| 2047 | } | ||
| 2048 | } | ||
| 2049 | } | ||
| 2050 | else | ||
| 2051 | if (strcmp(type, "hashtags") == 0) { | ||
| 2052 | /* search this tag */ | ||
| 2053 | xs *tl = tag_search((char *)q, 0, 1); | ||
| 2054 | |||
| 2055 | if (xs_list_len(tl)) { | ||
| 2056 | xs *d = xs_dict_new(); | ||
| 2057 | |||
| 2058 | d = xs_dict_append(d, "name", q); | ||
| 2059 | xs *url = xs_fmt("%s?t=%s", srv_baseurl, q); | ||
| 2060 | d = xs_dict_append(d, "url", url); | ||
| 2061 | d = xs_dict_append(d, "history", xs_stock_list); | ||
| 2062 | |||
| 2063 | htl = xs_list_append(htl, d); | ||
| 2046 | } | 2064 | } |
| 2047 | } | 2065 | } |
| 2048 | } | 2066 | } |