diff options
-rw-r--r-- | README.md | 7 | ||||
-rw-r--r-- | mastoapi.c | 14 |
2 files changed, 17 insertions, 4 deletions
@@ -58,12 +58,19 @@ Run `make` and then `make install` as root. If you're compiling on NetBSD, you should use the specific provided Makefile and run `make -f Makefile.NetBSD` and then `make -f Makefile.NetBSD install` as root. + From version 2.27, `snac` includes support for the Mastodon API; if you are not interested on it, you can compile it out by running ```sh make CFLAGS=-DNO_MASTODON_API ``` +If your compilation process complains about undefined references of `shm_open()` and `shm_unlink()` (it happens, for example, on 20.04.6 LTS), you need to tell `make` to add the `rt` library to the final linking command as follows: + +```sh +make LDFLAGS=-lrt +``` + See the administrator manual on how to proceed from here. ## Testing via Docker @@ -494,16 +494,20 @@ xs_str *mastoapi_id(const xs_dict *msg) xs_dict *mastoapi_account(const xs_dict *actor) /* converts an ActivityPub actor to a Mastodon account */ { - xs_dict *acct = xs_dict_new(); + 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"); - xs *acct_md5 = xs_md5_hex(id, strlen(id)); + xs_dict *acct = xs_dict_new(); + xs *acct_md5 = xs_md5_hex(id, strlen(id)); acct = xs_dict_append(acct, "id", acct_md5); acct = xs_dict_append(acct, "username", prefu); acct = xs_dict_append(acct, "display_name", display_name); @@ -711,6 +715,8 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg) return NULL; xs *acct = mastoapi_account(actor); + if (acct == NULL) + return NULL; xs *idx = NULL; xs *ixc = NULL; |