summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2024-02-05 19:34:27 +0100
committerGravatar default2024-02-05 19:34:27 +0100
commit4e35b4b865512b0616f1b9dd437ad12cf2953848 (patch)
tree194e305427675c9ac06cab23c45f7553d83a1673
parentBumped version. (diff)
downloadsnac2-4e35b4b865512b0616f1b9dd437ad12cf2953848.tar.gz
snac2-4e35b4b865512b0616f1b9dd437ad12cf2953848.tar.xz
snac2-4e35b4b865512b0616f1b9dd437ad12cf2953848.zip
Added paging to notify_list(), and use it in the notifications page.
-rw-r--r--data.c6
-rw-r--r--html.c6
-rw-r--r--mastoapi.c2
-rw-r--r--snac.h2
4 files changed, 8 insertions, 8 deletions
diff --git a/data.c b/data.c
index dfe1c4e..642dab4 100644
--- a/data.c
+++ b/data.c
@@ -2084,7 +2084,7 @@ xs_dict *notify_get(snac *snac, const char *id)
2084} 2084}
2085 2085
2086 2086
2087xs_list *notify_list(snac *snac) 2087xs_list *notify_list(snac *snac, int skip, int show)
2088/* returns a list of notification ids */ 2088/* returns a list of notification ids */
2089{ 2089{
2090 xs *idx = xs_fmt("%s/notify.idx", snac->basedir); 2090 xs *idx = xs_fmt("%s/notify.idx", snac->basedir);
@@ -2115,7 +2115,7 @@ xs_list *notify_list(snac *snac)
2115 pthread_mutex_unlock(&data_mutex); 2115 pthread_mutex_unlock(&data_mutex);
2116 } 2116 }
2117 2117
2118 return index_list_desc(idx, 0, 64); 2118 return index_list_desc(idx, skip, show);
2119} 2119}
2120 2120
2121 2121
@@ -2123,7 +2123,7 @@ int notify_new_num(snac *snac)
2123/* counts the number of new notifications */ 2123/* counts the number of new notifications */
2124{ 2124{
2125 xs *t = notify_check_time(snac, 0); 2125 xs *t = notify_check_time(snac, 0);
2126 xs *lst = notify_list(snac); 2126 xs *lst = notify_list(snac, 0, XS_ALL);
2127 int cnt = 0; 2127 int cnt = 0;
2128 2128
2129 xs_list *p = lst; 2129 xs_list *p = lst;
diff --git a/html.c b/html.c
index 85ec786..0508784 100644
--- a/html.c
+++ b/html.c
@@ -2135,9 +2135,9 @@ xs_str *html_people(snac *user)
2135} 2135}
2136 2136
2137 2137
2138xs_str *html_notifications(snac *user) 2138xs_str *html_notifications(snac *user, int skip, int show)
2139{ 2139{
2140 xs *n_list = notify_list(user); 2140 xs *n_list = notify_list(user, skip, show);
2141 xs *n_time = notify_check_time(user, 0); 2141 xs *n_time = notify_check_time(user, 0);
2142 2142
2143 xs_html *body = html_user_body(user, 0); 2143 xs_html *body = html_user_body(user, 0);
@@ -2428,7 +2428,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
2428 status = 401; 2428 status = 401;
2429 } 2429 }
2430 else { 2430 else {
2431 *body = html_notifications(&snac); 2431 *body = html_notifications(&snac, skip, show);
2432 *b_size = strlen(*body); 2432 *b_size = strlen(*body);
2433 status = 200; 2433 status = 200;
2434 } 2434 }
diff --git a/mastoapi.c b/mastoapi.c
index f1af7ba..267f842 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -1542,7 +1542,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1542 else 1542 else
1543 if (strcmp(cmd, "/v1/notifications") == 0) { /** **/ 1543 if (strcmp(cmd, "/v1/notifications") == 0) { /** **/
1544 if (logged_in) { 1544 if (logged_in) {
1545 xs *l = notify_list(&snac1); 1545 xs *l = notify_list(&snac1, 0, 64);
1546 xs *out = xs_list_new(); 1546 xs *out = xs_list_new();
1547 xs_list *p = l; 1547 xs_list *p = l;
1548 xs_dict *v; 1548 xs_dict *v;
diff --git a/snac.h b/snac.h
index 45861f8..cf2cf38 100644
--- a/snac.h
+++ b/snac.h
@@ -188,7 +188,7 @@ void notify_add(snac *snac, const char *type, const char *utype,
188 const char *actor, const char *objid); 188 const char *actor, const char *objid);
189xs_dict *notify_get(snac *snac, const char *id); 189xs_dict *notify_get(snac *snac, const char *id);
190int notify_new_num(snac *snac); 190int notify_new_num(snac *snac);
191xs_list *notify_list(snac *snac); 191xs_list *notify_list(snac *snac, int skip, int show);
192void notify_clear(snac *snac); 192void notify_clear(snac *snac);
193 193
194void inbox_add(const char *inbox); 194void inbox_add(const char *inbox);