diff options
| author | default <nobody@localhost> | 2024-09-18 10:59:42 +0200 |
|---|---|---|
| committer | default <nobody@localhost> | 2024-09-18 10:59:42 +0200 |
| commit | 0f3c60d1ee1bdceb4f7ce02609b85d6702812302 (patch) | |
| tree | 8dc2fef1660e0427c2006ccb225ee4b51d744d76 /main.c | |
| parent | 3155a80723904a9a44de98b9671c3f6b96d531bf (diff) | |
New command-line command 'aka'.
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -47,6 +47,7 @@ int usage(void) printf("unlimit {basedir} {uid} {actor} Unlimits an actor\n"); printf("verify_links {basedir} {uid} Verifies a user's links (in the metadata)\n"); printf("search {basedir} {uid} {regex} Searches posts by content\n"); + printf("aka {basedir} {uid} {actor} Sets actor (@user@host or url) as an a.k.a.\n"); return 1; } @@ -269,6 +270,32 @@ int main(int argc, char *argv[]) if ((url = GET_ARGV()) == NULL) return usage(); + if (strcmp(cmd, "aka") == 0) { /** **/ + xs *actor = NULL; + xs *uid = NULL; + int status = HTTP_STATUS_OK; + + if (*url == '\0') + actor = xs_dup(""); + else + status = webfinger_request(url, &actor, &uid); + + if (valid_status(status)) { + snac.config = xs_dict_set(snac.config, "aka", actor); + + xs *fn = xs_fmt("%s/user.json", snac.basedir); + FILE *f; + if ((f = fopen(fn, "w")) != NULL) { + xs_json_dump(snac.config, 4, f); + fclose(f); + } + } + else + snac_log(&snac, xs_fmt("Webfinger error for %s %d", url, status)); + + return 0; + } + if (strcmp(cmd, "webfinger_s") == 0) { /** **/ xs *actor = NULL; xs *uid = NULL; |