diff options
| -rw-r--r-- | main.c | 27 |
1 files changed, 27 insertions, 0 deletions
| @@ -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; |