mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
Deleted repeated code.
This commit is contained in:
parent
40fa322c54
commit
3e1944abbf
1 changed files with 5 additions and 4 deletions
|
@ -501,22 +501,23 @@ xs_dict *mastoapi_account(const xs_dict *actor)
|
||||||
/* converts an ActivityPub actor to a Mastodon account */
|
/* converts an ActivityPub actor to a Mastodon account */
|
||||||
{
|
{
|
||||||
xs_dict *acct = xs_dict_new();
|
xs_dict *acct = xs_dict_new();
|
||||||
|
const char *prefu = xs_dict_get(actor, "preferredUsername");
|
||||||
|
|
||||||
const char *display_name = xs_dict_get(actor, "name");
|
const char *display_name = xs_dict_get(actor, "name");
|
||||||
if (xs_is_null(display_name) || *display_name == '\0')
|
if (xs_is_null(display_name) || *display_name == '\0')
|
||||||
display_name = xs_dict_get(actor, "preferredUsername");
|
display_name = prefu;
|
||||||
|
|
||||||
const char *id = xs_dict_get(actor, "id");
|
const char *id = xs_dict_get(actor, "id");
|
||||||
const char *pub = xs_dict_get(actor, "published");
|
const char *pub = xs_dict_get(actor, "published");
|
||||||
xs *acct_md5 = xs_md5_hex(id, strlen(id));
|
xs *acct_md5 = xs_md5_hex(id, strlen(id));
|
||||||
acct = xs_dict_append(acct, "id", acct_md5);
|
acct = xs_dict_append(acct, "id", acct_md5);
|
||||||
acct = xs_dict_append(acct, "username", xs_dict_get(actor, "preferredUsername"));
|
acct = xs_dict_append(acct, "username", prefu);
|
||||||
acct = xs_dict_append(acct, "display_name", display_name);
|
acct = xs_dict_append(acct, "display_name", display_name);
|
||||||
|
|
||||||
{
|
{
|
||||||
/* create the acct field as user@host */
|
/* create the acct field as user@host */
|
||||||
xs *l = xs_split(id, "/");
|
xs *l = xs_split(id, "/");
|
||||||
xs *fquid = xs_fmt("%s@%s", xs_dict_get(actor, "preferredUsername"), xs_list_get(l, 2));
|
xs *fquid = xs_fmt("%s@%s", prefu, xs_list_get(l, 2));
|
||||||
acct = xs_dict_append(acct, "acct", fquid);
|
acct = xs_dict_append(acct, "acct", fquid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue