commit 0f3c60d1ee1bdceb4f7ce02609b85d6702812302
parent 3155a80723904a9a44de98b9671c3f6b96d531bf
Author: default <nobody@localhost>
Date: Wed, 18 Sep 2024 10:59:42 +0200
New command-line command 'aka'.
Diffstat:
M | main.c | | | 27 | +++++++++++++++++++++++++++ |
1 file changed, 27 insertions(+), 0 deletions(-)
diff --git 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;