summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--activitypub.c16
-rw-r--r--data.c23
-rw-r--r--snac.h4
3 files changed, 37 insertions, 6 deletions
diff --git a/activitypub.c b/activitypub.c
index 5ab7a96..8a38257 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -761,10 +761,24 @@ int activitypub_get_handler(d_char *req, char *q_path,
761 else 761 else
762 if (strcmp(p_path, "outbox") == 0) { 762 if (strcmp(p_path, "outbox") == 0) {
763 xs *id = xs_fmt("%s/outbox", snac.actor); 763 xs *id = xs_fmt("%s/outbox", snac.actor);
764 xs *elems = local_list(&snac, 40);
765 xs *list = xs_list_new();
764 msg = msg_collection(&snac, id); 766 msg = msg_collection(&snac, id);
767 char *p, *v;
768
769 p = elems;
770 while (xs_list_iter(&p, &v)) {
771 xs *i = timeline_get(&snac, v);
772 char *type = xs_dict_get(i, "type");
773 char *id = xs_dict_get(i, "id");
774
775 if (type && id && strcmp(type, "Note") == 0 && xs_startswith(id, snac.actor))
776 list = xs_list_append(list, i);
777 }
765 778
766 /* replace the 'orderedItems' with the latest posts */ 779 /* replace the 'orderedItems' with the latest posts */
767 /* ... */ 780 msg = xs_dict_set(msg, "orderedItems", list);
781 msg = xs_dict_set(msg, "totalItems", xs_number_new(xs_list_len(list)));
768 } 782 }
769 else 783 else
770 if (strcmp(p_path, "followers") == 0 || strcmp(p_path, "following") == 0) { 784 if (strcmp(p_path, "followers") == 0 || strcmp(p_path, "following") == 0) {
diff --git a/data.c b/data.c
index 97cf8b4..6ea1bae 100644
--- a/data.c
+++ b/data.c
@@ -357,16 +357,19 @@ d_char *timeline_get(snac *snac, char *fn)
357} 357}
358 358
359 359
360d_char *timeline_list(snac *snac) 360d_char *_timeline_list(snac *snac, char *directory, int max)
361/* returns a list of the timeline filenames */ 361/* returns a list of the timeline filenames */
362{ 362{
363 d_char *list; 363 d_char *list;
364 xs *spec = xs_fmt("%s/timeline/" "*.json", snac->basedir); 364 xs *spec = xs_fmt("%s/%s/" "*.json", snac->basedir, directory);
365 glob_t globbuf; 365 glob_t globbuf;
366 int max; 366 int c_max;
367 367
368 /* maximum number of items in the timeline */ 368 /* maximum number of items in the timeline */
369 max = xs_number_get(xs_dict_get(srv_config, "max_timeline_entries")); 369 c_max = xs_number_get(xs_dict_get(srv_config, "max_timeline_entries"));
370
371 if (max > c_max)
372 max = c_max;
370 373
371 list = xs_list_new(); 374 list = xs_list_new();
372 375
@@ -390,6 +393,18 @@ d_char *timeline_list(snac *snac)
390} 393}
391 394
392 395
396d_char *timeline_list(snac *snac, int max)
397{
398 return _timeline_list(snac, "timeline", max);
399}
400
401
402d_char *local_list(snac *snac, int max)
403{
404 return _timeline_list(snac, "local", max);
405}
406
407
393d_char *_timeline_new_fn(snac *snac, char *id) 408d_char *_timeline_new_fn(snac *snac, char *id)
394/* creates a new filename */ 409/* creates a new filename */
395{ 410{
diff --git a/snac.h b/snac.h
index 2b76939..209acb2 100644
--- a/snac.h
+++ b/snac.h
@@ -59,10 +59,12 @@ int timeline_here(snac *snac, char *id);
59d_char *timeline_find(snac *snac, char *id); 59d_char *timeline_find(snac *snac, char *id);
60void timeline_del(snac *snac, char *id); 60void timeline_del(snac *snac, char *id);
61d_char *timeline_get(snac *snac, char *fn); 61d_char *timeline_get(snac *snac, char *fn);
62d_char *timeline_list(snac *snac); 62d_char *timeline_list(snac *snac, int max);
63int timeline_add(snac *snac, char *id, char *o_msg, char *parent, char *referrer); 63int timeline_add(snac *snac, char *id, char *o_msg, char *parent, char *referrer);
64void timeline_admire(snac *snac, char *id, char *admirer, int like); 64void timeline_admire(snac *snac, char *id, char *admirer, int like);
65 65
66d_char *local_list(snac *snac, int max);
67
66int following_add(snac *snac, char *actor, char *msg); 68int following_add(snac *snac, char *actor, char *msg);
67int following_del(snac *snac, char *actor); 69int following_del(snac *snac, char *actor);
68int following_check(snac *snac, char *actor); 70int following_check(snac *snac, char *actor);