From 35c611b8b901c59f2532b691ad6b25ded86938f9 Mon Sep 17 00:00:00 2001 From: default Date: Fri, 14 Apr 2023 08:37:33 +0200 Subject: Fixed crash in notification list. --- mastoapi.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'mastoapi.c') diff --git a/mastoapi.c b/mastoapi.c index 4ce9b37..4ec9000 100644 --- a/mastoapi.c +++ b/mastoapi.c @@ -866,12 +866,17 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, xs_dict *v; while (xs_list_iter(&p, &v)) { - const char *type = xs_dict_get(v, "type"); - const char *objid = xs_dict_get(v, "objid"); + xs *noti = notify_get(&snac1, v); + + if (noti == NULL) + continue; + + const char *type = xs_dict_get(noti, "type"); + const char *objid = xs_dict_get(noti, "objid"); xs *actor = NULL; xs *entry = NULL; - if (!valid_status(object_get(xs_dict_get(v, "actor"), &actor))) + if (!valid_status(object_get(xs_dict_get(noti, "actor"), &actor))) continue; if (objid != NULL && !valid_status(object_get(objid, &entry))) @@ -896,15 +901,15 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, mn = xs_dict_append(mn, "type", type); - xs *id = xs_replace(xs_dict_get(v, "id"), ".", ""); + xs *id = xs_replace(xs_dict_get(noti, "id"), ".", ""); mn = xs_dict_append(mn, "id", id); - mn = xs_dict_append(mn, "created_at", xs_dict_get(v, "date")); + mn = xs_dict_append(mn, "created_at", xs_dict_get(noti, "date")); xs *acct = mastoapi_account(actor); mn = xs_dict_append(mn, "account", acct); - if (objid != NULL) { + if (strcmp(type, "follow") != 0 && !xs_is_null(objid)) { xs *st = mastoapi_status(&snac1, entry); mn = xs_dict_append(mn, "status", st); } -- cgit v1.2.3