summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/activitypub.c b/activitypub.c
index 7a7e346..59a69ec 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -1038,15 +1038,14 @@ xs_dict *msg_base(snac *snac, const char *type, const char *id,
1038} 1038}
1039 1039
1040 1040
1041xs_dict *msg_collection(snac *snac, const char *id) 1041xs_dict *msg_collection(snac *snac, const char *id, int items)
1042/* creates an empty OrderedCollection message */ 1042/* creates an empty OrderedCollection message */
1043{ 1043{
1044 xs_dict *msg = msg_base(snac, "OrderedCollection", id, NULL, NULL, NULL); 1044 xs_dict *msg = msg_base(snac, "OrderedCollection", id, NULL, NULL, NULL);
1045 xs *ol = xs_list_new(); 1045 xs *n = xs_number_new(items);
1046 1046
1047 msg = xs_dict_append(msg, "attributedTo", snac->actor); 1047 msg = xs_dict_append(msg, "attributedTo", snac->actor);
1048 msg = xs_dict_append(msg, "orderedItems", ol); 1048 msg = xs_dict_append(msg, "totalItems", n);
1049 msg = xs_dict_append(msg, "totalItems", xs_stock(0));
1050 1049
1051 return msg; 1050 return msg;
1052} 1051}
@@ -2850,7 +2849,6 @@ int activitypub_get_handler(const xs_dict *req, const char *q_path,
2850 if (strcmp(p_path, "outbox") == 0 || strcmp(p_path, "featured") == 0) { 2849 if (strcmp(p_path, "outbox") == 0 || strcmp(p_path, "featured") == 0) {
2851 xs *id = xs_fmt("%s/%s", snac.actor, p_path); 2850 xs *id = xs_fmt("%s/%s", snac.actor, p_path);
2852 xs *list = xs_list_new(); 2851 xs *list = xs_list_new();
2853 msg = msg_collection(&snac, id);
2854 const char *v; 2852 const char *v;
2855 int tc = 0; 2853 int tc = 0;
2856 2854
@@ -2872,14 +2870,18 @@ int activitypub_get_handler(const xs_dict *req, const char *q_path,
2872 } 2870 }
2873 2871
2874 /* replace the 'orderedItems' with the latest posts */ 2872 /* replace the 'orderedItems' with the latest posts */
2875 xs *items = xs_number_new(xs_list_len(list)); 2873 msg = msg_collection(&snac, id, xs_list_len(list));
2876 msg = xs_dict_set(msg, "orderedItems", list); 2874 msg = xs_dict_set(msg, "orderedItems", list);
2877 msg = xs_dict_set(msg, "totalItems", items);
2878 } 2875 }
2879 else 2876 else
2880 if (strcmp(p_path, "followers") == 0 || strcmp(p_path, "following") == 0) { 2877 if (strcmp(p_path, "followers") == 0) {
2881 xs *id = xs_fmt("%s/%s", snac.actor, p_path); 2878 xs *id = xs_fmt("%s/%s", snac.actor, p_path);
2882 msg = msg_collection(&snac, id); 2879 msg = msg_collection(&snac, id, 0);
2880 }
2881 else
2882 if (strcmp(p_path, "following") == 0) {
2883 xs *id = xs_fmt("%s/%s", snac.actor, p_path);
2884 msg = msg_collection(&snac, id, 0);
2883 } 2885 }
2884 else 2886 else
2885 if (xs_startswith(p_path, "p/")) { 2887 if (xs_startswith(p_path, "p/")) {