summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2024-01-08 17:26:33 +0100
committerdefault <nobody@localhost>2024-01-08 17:26:33 +0100
commit5172dc1e8f422572c708d2b1762ac15088c30a3f (patch)
treed67ec1e42c894bc643a5a9a73fadf43b690a937b
parentd05399986db1af7729554c7710f674551174364c (diff)
Webfinger queries are cached, as they should.
-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
headers = xs_dict_append(headers, "accept", "application/json");
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? */
if (strcmp(host, xs_dict_get(srv_config, "host")) == 0) {
/* 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);
}
- if (valid_status(status)) {
- xs *obj = xs_json_loads(payload);
+ if (obj == NULL && valid_status(status) && payload) {
+ obj = xs_json_loads(payload);
+ object_add(qs, obj);
+ }
+ if (obj) {
if (user != NULL) {
char *subject = xs_dict_get(obj, "subject");