summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
Diffstat (limited to 'data.c')
-rw-r--r--data.c45
1 files changed, 39 insertions, 6 deletions
diff --git a/data.c b/data.c
index 40382d2..50c6121 100644
--- a/data.c
+++ b/data.c
@@ -1489,16 +1489,28 @@ xs_str *user_index_fn(snac *user, const char *idx_name)
1489} 1489}
1490 1490
1491 1491
1492xs_list *timeline_simple_list(snac *user, const char *idx_name, int skip, int show) 1492xs_list *timeline_simple_list(snac *user, const char *idx_name, int skip, int show, int *more)
1493/* returns a timeline (with all entries) */ 1493/* returns a timeline (with all entries) */
1494{ 1494{
1495 xs *idx = user_index_fn(user, idx_name); 1495 xs *idx = user_index_fn(user, idx_name);
1496 1496
1497 return index_list_desc(idx, skip, show); 1497 /* if a more flag is sent, request one more */
1498 xs_list *lst = index_list_desc(idx, skip, show + (more != NULL ? 1 : 0));
1499
1500 if (more != NULL) {
1501 if (xs_list_len(lst) > show) {
1502 *more = 1;
1503 lst = xs_list_del(lst, -1);
1504 }
1505 else
1506 *more = 0;
1507 }
1508
1509 return lst;
1498} 1510}
1499 1511
1500 1512
1501xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show) 1513xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show, int *more)
1502/* returns a timeline (only top level entries) */ 1514/* returns a timeline (only top level entries) */
1503{ 1515{
1504 int c_max; 1516 int c_max;
@@ -1510,12 +1522,33 @@ xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show)
1510 if (show > c_max) 1522 if (show > c_max)
1511 show = c_max; 1523 show = c_max;
1512 1524
1513 xs *list = timeline_simple_list(snac, idx_name, skip, show); 1525 xs *list = timeline_simple_list(snac, idx_name, skip, show, more);
1514 1526
1515 return timeline_top_level(snac, list); 1527 return timeline_top_level(snac, list);
1516} 1528}
1517 1529
1518 1530
1531void timeline_add_mark(snac *user)
1532/* adds an "already seen" mark to the private timeline */
1533{
1534 xs *fn = xs_fmt("%s/private.idx", user->basedir);
1535 char last_entry[MD5_HEX_SIZE] = "";
1536 FILE *f;
1537
1538 /* get the last entry in the index */
1539 if ((f = fopen(fn, "r")) != NULL) {
1540 index_desc_first(f, last_entry, 0);
1541 fclose(f);
1542 }
1543
1544 /* is the last entry *not* a mark? */
1545 if (strcmp(last_entry, MD5_ALREADY_SEEN_MARK) != 0) {
1546 /* add it */
1547 index_add_md5(fn, MD5_ALREADY_SEEN_MARK);
1548 }
1549}
1550
1551
1519xs_str *instance_index_fn(void) 1552xs_str *instance_index_fn(void)
1520{ 1553{
1521 return xs_fmt("%s/public.idx", srv_basedir); 1554 return xs_fmt("%s/public.idx", srv_basedir);
@@ -2709,9 +2742,9 @@ xs_list *content_search(snac *user, const char *regex,
2709 const char *md5s[3] = {0}; 2742 const char *md5s[3] = {0};
2710 int c[3] = {0}; 2743 int c[3] = {0};
2711 2744
2712 tls[0] = timeline_simple_list(user, "public", 0, XS_ALL); /* public */ 2745 tls[0] = timeline_simple_list(user, "public", 0, XS_ALL, NULL); /* public */
2713 tls[1] = timeline_instance_list(0, XS_ALL); /* instance */ 2746 tls[1] = timeline_instance_list(0, XS_ALL); /* instance */
2714 tls[2] = priv ? timeline_simple_list(user, "private", 0, XS_ALL) : xs_list_new(); /* private or none */ 2747 tls[2] = priv ? timeline_simple_list(user, "private", 0, XS_ALL, NULL) : xs_list_new(); /* private or none */
2715 2748
2716 /* first positioning */ 2749 /* first positioning */
2717 for (int n = 0; n < 3; n++) 2750 for (int n = 0; n < 3; n++)