summaryrefslogtreecommitdiff
path: root/webfinger.c
diff options
context:
space:
mode:
authorGravatar default2024-01-08 17:26:33 +0100
committerGravatar default2024-01-08 17:26:33 +0100
commit5172dc1e8f422572c708d2b1762ac15088c30a3f (patch)
treed67ec1e42c894bc643a5a9a73fadf43b690a937b /webfinger.c
parentNew state variable top_job_fifo_size. (diff)
downloadsnac2-5172dc1e8f422572c708d2b1762ac15088c30a3f.tar.gz
snac2-5172dc1e8f422572c708d2b1762ac15088c30a3f.tar.xz
snac2-5172dc1e8f422572c708d2b1762ac15088c30a3f.zip
Webfinger queries are cached, as they should.
Diffstat (limited to 'webfinger.c')
-rw-r--r--webfinger.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/webfinger.c b/webfinger.c
index e3d8691..2184097 100644
--- a/webfinger.c
+++ b/webfinger.c
@@ -46,6 +46,13 @@ int webfinger_request_signed(snac *snac, const char *qs, char **actor, char **us
46 headers = xs_dict_append(headers, "accept", "application/json"); 46 headers = xs_dict_append(headers, "accept", "application/json");
47 headers = xs_dict_append(headers, "user-agent", USER_AGENT); 47 headers = xs_dict_append(headers, "user-agent", USER_AGENT);
48 48
49 xs *obj = NULL;
50
51 /* is it cached? */
52 if (valid_status(status = object_get(qs, &obj))) {
53 /* nothing more to do */
54 }
55 else
49 /* is it a query about one of us? */ 56 /* is it a query about one of us? */
50 if (strcmp(host, xs_dict_get(srv_config, "host")) == 0) { 57 if (strcmp(host, xs_dict_get(srv_config, "host")) == 0) {
51 /* route internally */ 58 /* route internally */
@@ -68,9 +75,12 @@ int webfinger_request_signed(snac *snac, const char *qs, char **actor, char **us
68 http_signed_request(snac, "GET", url, headers, NULL, 0, &status, &payload, &p_size, 0); 75 http_signed_request(snac, "GET", url, headers, NULL, 0, &status, &payload, &p_size, 0);
69 } 76 }
70 77
71 if (valid_status(status)) { 78 if (obj == NULL && valid_status(status) && payload) {
72 xs *obj = xs_json_loads(payload); 79 obj = xs_json_loads(payload);
80 object_add(qs, obj);
81 }
73 82
83 if (obj) {
74 if (user != NULL) { 84 if (user != NULL) {
75 char *subject = xs_dict_get(obj, "subject"); 85 char *subject = xs_dict_get(obj, "subject");
76 86