summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorGravatar default2024-09-18 10:59:42 +0200
committerGravatar default2024-09-18 10:59:42 +0200
commit0f3c60d1ee1bdceb4f7ce02609b85d6702812302 (patch)
tree8dc2fef1660e0427c2006ccb225ee4b51d744d76 /main.c
parentWhile processing a 'Move', retry failed actor retrieval (it may be a transien... (diff)
downloadpenes-snac2-0f3c60d1ee1bdceb4f7ce02609b85d6702812302.tar.gz
penes-snac2-0f3c60d1ee1bdceb4f7ce02609b85d6702812302.tar.xz
penes-snac2-0f3c60d1ee1bdceb4f7ce02609b85d6702812302.zip
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)
47 printf("unlimit {basedir} {uid} {actor} Unlimits an actor\n"); 47 printf("unlimit {basedir} {uid} {actor} Unlimits an actor\n");
48 printf("verify_links {basedir} {uid} Verifies a user's links (in the metadata)\n"); 48 printf("verify_links {basedir} {uid} Verifies a user's links (in the metadata)\n");
49 printf("search {basedir} {uid} {regex} Searches posts by content\n"); 49 printf("search {basedir} {uid} {regex} Searches posts by content\n");
50 printf("aka {basedir} {uid} {actor} Sets actor (@user@host or url) as an a.k.a.\n");
50 51
51 return 1; 52 return 1;
52} 53}
@@ -269,6 +270,32 @@ int main(int argc, char *argv[])
269 if ((url = GET_ARGV()) == NULL) 270 if ((url = GET_ARGV()) == NULL)
270 return usage(); 271 return usage();
271 272
273 if (strcmp(cmd, "aka") == 0) { /** **/
274 xs *actor = NULL;
275 xs *uid = NULL;
276 int status = HTTP_STATUS_OK;
277
278 if (*url == '\0')
279 actor = xs_dup("");
280 else
281 status = webfinger_request(url, &actor, &uid);
282
283 if (valid_status(status)) {
284 snac.config = xs_dict_set(snac.config, "aka", actor);
285
286 xs *fn = xs_fmt("%s/user.json", snac.basedir);
287 FILE *f;
288 if ((f = fopen(fn, "w")) != NULL) {
289 xs_json_dump(snac.config, 4, f);
290 fclose(f);
291 }
292 }
293 else
294 snac_log(&snac, xs_fmt("Webfinger error for %s %d", url, status));
295
296 return 0;
297 }
298
272 if (strcmp(cmd, "webfinger_s") == 0) { /** **/ 299 if (strcmp(cmd, "webfinger_s") == 0) { /** **/
273 xs *actor = NULL; 300 xs *actor = NULL;
274 xs *uid = NULL; 301 xs *uid = NULL;