aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2024-09-18 10:59:42 +0200
committerdefault <nobody@localhost>2024-09-18 10:59:42 +0200
commit0f3c60d1ee1bdceb4f7ce02609b85d6702812302 (patch)
tree8dc2fef1660e0427c2006ccb225ee4b51d744d76 /main.c
parent3155a80723904a9a44de98b9671c3f6b96d531bf (diff)
New command-line command 'aka'.
Diffstat (limited to 'main.c')
-rw-r--r--main.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/main.c b/main.c
index 62d6484..6dc1ffe 100644
--- a/main.c
+++ b/main.c
@@ -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;