mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 05:15:04 +00:00
Webfinger queries are cached, as they should.
This commit is contained in:
parent
d05399986d
commit
5172dc1e8f
1 changed files with 12 additions and 2 deletions
14
webfinger.c
14
webfinger.c
|
@ -46,6 +46,13 @@ int webfinger_request_signed(snac *snac, const char *qs, char **actor, char **us
|
||||||
headers = xs_dict_append(headers, "accept", "application/json");
|
headers = xs_dict_append(headers, "accept", "application/json");
|
||||||
headers = xs_dict_append(headers, "user-agent", USER_AGENT);
|
headers = xs_dict_append(headers, "user-agent", USER_AGENT);
|
||||||
|
|
||||||
|
xs *obj = NULL;
|
||||||
|
|
||||||
|
/* is it cached? */
|
||||||
|
if (valid_status(status = object_get(qs, &obj))) {
|
||||||
|
/* nothing more to do */
|
||||||
|
}
|
||||||
|
else
|
||||||
/* is it a query about one of us? */
|
/* is it a query about one of us? */
|
||||||
if (strcmp(host, xs_dict_get(srv_config, "host")) == 0) {
|
if (strcmp(host, xs_dict_get(srv_config, "host")) == 0) {
|
||||||
/* route internally */
|
/* route internally */
|
||||||
|
@ -68,9 +75,12 @@ int webfinger_request_signed(snac *snac, const char *qs, char **actor, char **us
|
||||||
http_signed_request(snac, "GET", url, headers, NULL, 0, &status, &payload, &p_size, 0);
|
http_signed_request(snac, "GET", url, headers, NULL, 0, &status, &payload, &p_size, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid_status(status)) {
|
if (obj == NULL && valid_status(status) && payload) {
|
||||||
xs *obj = xs_json_loads(payload);
|
obj = xs_json_loads(payload);
|
||||||
|
object_add(qs, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj) {
|
||||||
if (user != NULL) {
|
if (user != NULL) {
|
||||||
char *subject = xs_dict_get(obj, "subject");
|
char *subject = xs_dict_get(obj, "subject");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue