summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2024-01-12 11:03:29 +0100
committerdefault <nobody@localhost>2024-01-12 11:03:29 +0100
commit9185cc4baa70b77336aa5a862cd23c3913800c0c (patch)
treead574ce59c8e56b0b5a7a0922d3df7fca59f9b2f /mastoapi.c
parent5532a3e8bdec92ada01bd844f796f0f95e9e312e (diff)
Minor tweak for better corruption detection.
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/mastoapi.c b/mastoapi.c
index d3221c1..a81e86e 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -494,18 +494,18 @@ xs_str *mastoapi_id(const xs_dict *msg)
xs_dict *mastoapi_account(const xs_dict *actor)
/* converts an ActivityPub actor to a Mastodon account */
{
+ const char *id = xs_dict_get(actor, "id");
+ const char *pub = xs_dict_get(actor, "published");
+
+ if (xs_type(id) != XSTYPE_STRING)
+ return NULL;
+
const char *prefu = xs_dict_get(actor, "preferredUsername");
const char *display_name = xs_dict_get(actor, "name");
if (xs_is_null(display_name) || *display_name == '\0')
display_name = prefu;
- const char *id = xs_dict_get(actor, "id");
- const char *pub = xs_dict_get(actor, "published");
-
- if (xs_is_null(id))
- return NULL;
-
xs_dict *acct = xs_dict_new();
xs *acct_md5 = xs_md5_hex(id, strlen(id));
acct = xs_dict_append(acct, "id", acct_md5);