summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authorGravatar default2024-11-17 11:08:25 +0100
committerGravatar default2024-11-17 11:08:25 +0100
commit437829a83376b9094689469d7d4c30eab48f556e (patch)
tree8211b32c97c20febfbace091f88367512c5c97b4 /mastoapi.c
parentmastoapi: added more checks in the notifications code. (diff)
downloadsnac2-437829a83376b9094689469d7d4c30eab48f556e.tar.gz
snac2-437829a83376b9094689469d7d4c30eab48f556e.tar.xz
snac2-437829a83376b9094689469d7d4c30eab48f556e.zip
mastoapi: more tweaks to notifications code.
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/mastoapi.c b/mastoapi.c
index f80c730..73b9a8b 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -1727,11 +1727,11 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1727 if (logged_in) { 1727 if (logged_in) {
1728 xs *l = notify_list(&snac1, 0, 64); 1728 xs *l = notify_list(&snac1, 0, 64);
1729 xs *out = xs_list_new(); 1729 xs *out = xs_list_new();
1730 xs_list *p = l;
1731 const xs_dict *v; 1730 const xs_dict *v;
1732 const xs_list *excl = xs_dict_get(args, "exclude_types[]"); 1731 const xs_list *excl = xs_dict_get(args, "exclude_types[]");
1732 const char *max_id = xs_dict_get(args, "max_id");
1733 1733
1734 while (xs_list_iter(&p, &v)) { 1734 xs_list_foreach(l, v) {
1735 xs *noti = notify_get(&snac1, v); 1735 xs *noti = notify_get(&snac1, v);
1736 1736
1737 if (noti == NULL) 1737 if (noti == NULL)
@@ -1740,6 +1740,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1740 const char *type = xs_dict_get(noti, "type"); 1740 const char *type = xs_dict_get(noti, "type");
1741 const char *utype = xs_dict_get(noti, "utype"); 1741 const char *utype = xs_dict_get(noti, "utype");
1742 const char *objid = xs_dict_get(noti, "objid"); 1742 const char *objid = xs_dict_get(noti, "objid");
1743 const char *id = xs_dict_get(noti, "id");
1744 xs *fid = xs_replace(id, ".", "");
1743 xs *actor = NULL; 1745 xs *actor = NULL;
1744 xs *entry = NULL; 1746 xs *entry = NULL;
1745 1747
@@ -1752,6 +1754,13 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1752 if (is_hidden(&snac1, objid)) 1754 if (is_hidden(&snac1, objid))
1753 continue; 1755 continue;
1754 1756
1757 if (max_id) {
1758 if (strcmp(fid, max_id) == 0)
1759 max_id = NULL;
1760
1761 continue;
1762 }
1763
1755 /* convert the type */ 1764 /* convert the type */
1756 if (strcmp(type, "Like") == 0 || strcmp(type, "EmojiReact") == 0) 1765 if (strcmp(type, "Like") == 0 || strcmp(type, "EmojiReact") == 0)
1757 type = "favourite"; 1766 type = "favourite";
@@ -1778,8 +1787,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1778 1787
1779 mn = xs_dict_append(mn, "type", type); 1788 mn = xs_dict_append(mn, "type", type);
1780 1789
1781 xs *id = xs_replace(xs_dict_get(noti, "id"), ".", ""); 1790 mn = xs_dict_append(mn, "id", fid);
1782 mn = xs_dict_append(mn, "id", id);
1783 1791
1784 mn = xs_dict_append(mn, "created_at", xs_dict_get(noti, "date")); 1792 mn = xs_dict_append(mn, "created_at", xs_dict_get(noti, "date"));
1785 1793