diff options
author | default <nobody@localhost> | 2024-02-16 05:47:18 +0100 |
---|---|---|
committer | default <nobody@localhost> | 2024-02-16 05:47:18 +0100 |
commit | 2da394aef4c8945d327f53376cf6f645c4bfe590 (patch) | |
tree | 92b8c77c5daf2f69ab95c51c088c1e850cc05bd6 /utils.c | |
parent | 79f79c0c6a441f5722c6a0ca38b8910015a27dbe (diff) |
Added 'accept' and 'user-agent' headers to verify_links().
Diffstat (limited to 'utils.c')
-rw-r--r-- | utils.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -418,6 +418,10 @@ void verify_links(snac *user) char *k, *v; int changed = 0; + xs *headers = xs_dict_new(); + headers = xs_dict_append(headers, "accept", "text/html"); + headers = xs_dict_append(headers, "user-agent", USER_AGENT " (link verify)"); + while (p && xs_dict_iter(&p, &k, &v)) { /* not an https link? skip */ if (!xs_startswith(v, "https:/" "/")) @@ -428,11 +432,11 @@ void verify_links(snac *user) xs *payload = NULL; int p_size = 0; - req = xs_http_request("GET", v, NULL, NULL, 0, &status, + req = xs_http_request("GET", v, headers, NULL, 0, &status, &payload, &p_size, 0); if (!valid_status(status)) { - snac_log(user, xs_fmt("verify link %s error %d", v, status)); + snac_log(user, xs_fmt("link %s verify error %d", v, status)); continue; } @@ -441,6 +445,7 @@ void verify_links(snac *user) xs_list *lp = ls; char *ll; + int vfied = 0; while (xs_list_iter(&lp, &ll)) { /* extract href and rel */ @@ -490,15 +495,23 @@ void verify_links(snac *user) user->links = xs_dict_set(user->links, v, verified_at); - changed++; + vfied = 1; - snac_log(user, xs_fmt("link %s verified at %s", v, verified_at)); + break; } else snac_debug(user, 1, xs_fmt("verify link %s rel='me' found but not related (%s)", v, href)); } } + + if (vfied) { + changed++; + snac_log(user, xs_fmt("link %s verified", v)); + } + else { + snac_log(user, xs_fmt("link %s not verified (rel='me' not found)", v)); + } } if (changed) { |