summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 5c29a93..51578ad 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -500,23 +500,24 @@ xs_str *mastoapi_id(const xs_dict *msg)
500xs_dict *mastoapi_account(const xs_dict *actor) 500xs_dict *mastoapi_account(const xs_dict *actor)
501/* converts an ActivityPub actor to a Mastodon account */ 501/* converts an ActivityPub actor to a Mastodon account */
502{ 502{
503 xs_dict *acct = xs_dict_new(); 503 xs_dict *acct = xs_dict_new();
504 const char *prefu = xs_dict_get(actor, "preferredUsername");
504 505
505 const char *display_name = xs_dict_get(actor, "name"); 506 const char *display_name = xs_dict_get(actor, "name");
506 if (xs_is_null(display_name) || *display_name == '\0') 507 if (xs_is_null(display_name) || *display_name == '\0')
507 display_name = xs_dict_get(actor, "preferredUsername"); 508 display_name = prefu;
508 509
509 const char *id = xs_dict_get(actor, "id"); 510 const char *id = xs_dict_get(actor, "id");
510 const char *pub = xs_dict_get(actor, "published"); 511 const char *pub = xs_dict_get(actor, "published");
511 xs *acct_md5 = xs_md5_hex(id, strlen(id)); 512 xs *acct_md5 = xs_md5_hex(id, strlen(id));
512 acct = xs_dict_append(acct, "id", acct_md5); 513 acct = xs_dict_append(acct, "id", acct_md5);
513 acct = xs_dict_append(acct, "username", xs_dict_get(actor, "preferredUsername")); 514 acct = xs_dict_append(acct, "username", prefu);
514 acct = xs_dict_append(acct, "display_name", display_name); 515 acct = xs_dict_append(acct, "display_name", display_name);
515 516
516 { 517 {
517 /* create the acct field as user@host */ 518 /* create the acct field as user@host */
518 xs *l = xs_split(id, "/"); 519 xs *l = xs_split(id, "/");
519 xs *fquid = xs_fmt("%s@%s", xs_dict_get(actor, "preferredUsername"), xs_list_get(l, 2)); 520 xs *fquid = xs_fmt("%s@%s", prefu, xs_list_get(l, 2));
520 acct = xs_dict_append(acct, "acct", fquid); 521 acct = xs_dict_append(acct, "acct", fquid);
521 } 522 }
522 523