diff options
| author | 2023-04-14 08:37:33 +0200 | |
|---|---|---|
| committer | 2023-04-14 08:37:33 +0200 | |
| commit | 35c611b8b901c59f2532b691ad6b25ded86938f9 (patch) | |
| tree | b06c27d1ea17559782059ef884a4acc542b7f9b3 | |
| parent | Added a dummy 'created_at' field for accounts that don't have a date. (diff) | |
| download | snac2-35c611b8b901c59f2532b691ad6b25ded86938f9.tar.gz snac2-35c611b8b901c59f2532b691ad6b25ded86938f9.tar.xz snac2-35c611b8b901c59f2532b691ad6b25ded86938f9.zip | |
Fixed crash in notification list.
| -rw-r--r-- | data.c | 6 | ||||
| -rw-r--r-- | mastoapi.c | 17 |
2 files changed, 13 insertions, 10 deletions
| @@ -1558,7 +1558,7 @@ xs_dict *notify_get(snac *snac, const char *id) | |||
| 1558 | 1558 | ||
| 1559 | 1559 | ||
| 1560 | xs_list *notify_list(snac *snac, int new_only) | 1560 | xs_list *notify_list(snac *snac, int new_only) |
| 1561 | /* returns a list of notifications, optionally only the new ones */ | 1561 | /* returns a list of notification ids, optionally only the new ones */ |
| 1562 | { | 1562 | { |
| 1563 | xs *t = NULL; | 1563 | xs *t = NULL; |
| 1564 | 1564 | ||
| @@ -1579,9 +1579,7 @@ xs_list *notify_list(snac *snac, int new_only) | |||
| 1579 | if (t != NULL && strcmp(id, t) < 0) | 1579 | if (t != NULL && strcmp(id, t) < 0) |
| 1580 | continue; | 1580 | continue; |
| 1581 | 1581 | ||
| 1582 | xs *noti = notify_get(snac, id); | 1582 | out = xs_list_append(out, id); |
| 1583 | |||
| 1584 | out = xs_list_append(out, noti); | ||
| 1585 | } | 1583 | } |
| 1586 | 1584 | ||
| 1587 | return out; | 1585 | return out; |
| @@ -866,12 +866,17 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 866 | xs_dict *v; | 866 | xs_dict *v; |
| 867 | 867 | ||
| 868 | while (xs_list_iter(&p, &v)) { | 868 | while (xs_list_iter(&p, &v)) { |
| 869 | const char *type = xs_dict_get(v, "type"); | 869 | xs *noti = notify_get(&snac1, v); |
| 870 | const char *objid = xs_dict_get(v, "objid"); | 870 | |
| 871 | if (noti == NULL) | ||
| 872 | continue; | ||
| 873 | |||
| 874 | const char *type = xs_dict_get(noti, "type"); | ||
| 875 | const char *objid = xs_dict_get(noti, "objid"); | ||
| 871 | xs *actor = NULL; | 876 | xs *actor = NULL; |
| 872 | xs *entry = NULL; | 877 | xs *entry = NULL; |
| 873 | 878 | ||
| 874 | if (!valid_status(object_get(xs_dict_get(v, "actor"), &actor))) | 879 | if (!valid_status(object_get(xs_dict_get(noti, "actor"), &actor))) |
| 875 | continue; | 880 | continue; |
| 876 | 881 | ||
| 877 | if (objid != NULL && !valid_status(object_get(objid, &entry))) | 882 | 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, | |||
| 896 | 901 | ||
| 897 | mn = xs_dict_append(mn, "type", type); | 902 | mn = xs_dict_append(mn, "type", type); |
| 898 | 903 | ||
| 899 | xs *id = xs_replace(xs_dict_get(v, "id"), ".", ""); | 904 | xs *id = xs_replace(xs_dict_get(noti, "id"), ".", ""); |
| 900 | mn = xs_dict_append(mn, "id", id); | 905 | mn = xs_dict_append(mn, "id", id); |
| 901 | 906 | ||
| 902 | mn = xs_dict_append(mn, "created_at", xs_dict_get(v, "date")); | 907 | mn = xs_dict_append(mn, "created_at", xs_dict_get(noti, "date")); |
| 903 | 908 | ||
| 904 | xs *acct = mastoapi_account(actor); | 909 | xs *acct = mastoapi_account(actor); |
| 905 | mn = xs_dict_append(mn, "account", acct); | 910 | mn = xs_dict_append(mn, "account", acct); |
| 906 | 911 | ||
| 907 | if (objid != NULL) { | 912 | if (strcmp(type, "follow") != 0 && !xs_is_null(objid)) { |
| 908 | xs *st = mastoapi_status(&snac1, entry); | 913 | xs *st = mastoapi_status(&snac1, entry); |
| 909 | mn = xs_dict_append(mn, "status", st); | 914 | mn = xs_dict_append(mn, "status", st); |
| 910 | } | 915 | } |