commit 578d70d

default  ·  2023-04-10 06:52:04 +0000 UTC
parent a65f191
More work in status entries.
1 files changed,  +58, -18
+58, -18
  1@@ -410,8 +410,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
  2         /* the private timeline */
  3         if (logged_in) {
  4             const char *max_id   = xs_dict_get(args, "max_id");
  5-            const char *since_id = xs_dict_get(args, "since_id");
  6-            const char *min_id   = xs_dict_get(args, "min_id");
  7+//            const char *since_id = xs_dict_get(args, "since_id");
  8+//            const char *min_id   = xs_dict_get(args, "min_id");
  9             const char *limit_s  = xs_dict_get(args, "limit");
 10             int limit = 20;
 11             int cnt = 0;
 12@@ -419,8 +419,9 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
 13             if (!xs_is_null(limit_s))
 14                 limit = atoi(limit_s);
 15 
 16-            xs *out      = xs_list_new();
 17             xs *timeline = timeline_list(&snac, "private", 0, XS_ALL);
 18+
 19+            xs *out      = xs_list_new();
 20             xs_list *p   = timeline;
 21             xs_str *v;
 22 
 23@@ -476,17 +477,20 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
 24 
 25                 acct = xs_dict_append(acct, "avatar", avatar);
 26 
 27-                xs *f  = xs_val_new(XSTYPE_FALSE);
 28-                xs *t  = xs_val_new(XSTYPE_TRUE);
 29-                xs *n  = xs_val_new(XSTYPE_NULL);
 30-                xs *el = xs_list_new();
 31-                xs *ed = xs_dict_new();
 32+                xs *f   = xs_val_new(XSTYPE_FALSE);
 33+                xs *t   = xs_val_new(XSTYPE_TRUE);
 34+                xs *n   = xs_val_new(XSTYPE_NULL);
 35+                xs *el  = xs_list_new();
 36+                xs *idx = NULL;
 37+                xs *ixc = NULL;
 38+
 39                 char *tmp;
 40+                id = xs_dict_get(msg, "id");
 41 
 42                 xs *st = xs_dict_new();
 43 
 44                 st = xs_dict_append(st, "id",           v);
 45-                st = xs_dict_append(st, "uri",          xs_dict_get(msg, "id"));
 46+                st = xs_dict_append(st, "uri",          id);
 47                 st = xs_dict_append(st, "created_at",   xs_dict_get(msg, "published"));
 48                 st = xs_dict_append(st, "account",      acct);
 49                 st = xs_dict_append(st, "content",      xs_dict_get(msg, "content"));
 50@@ -497,28 +501,64 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
 51                     tmp = f;
 52 
 53                 st = xs_dict_append(st, "sensitive",    tmp);
 54-                st = xs_dict_append(st, "spoiler_text", "");
 55+
 56+                tmp = xs_dict_get(msg, "summary");
 57+                if (xs_is_null(tmp))
 58+                    tmp = "";
 59+
 60+                st = xs_dict_append(st, "spoiler_text", tmp);
 61 
 62                 st = xs_dict_append(st, "media_attachments", el);
 63                 st = xs_dict_append(st, "mentions",          el);
 64                 st = xs_dict_append(st, "tags",              el);
 65                 st = xs_dict_append(st, "emojis",            el);
 66 
 67-                st = xs_dict_append(st, "reblogs_count", xs_number_new(0));
 68-                st = xs_dict_append(st, "favourites_count", xs_number_new(0));
 69-                st = xs_dict_append(st, "replies_count", xs_number_new(0));
 70+                xs_free(idx);
 71+                xs_free(ixc);
 72+                idx = object_likes(id);
 73+                ixc = xs_number_new(xs_list_len(idx));
 74+
 75+                st = xs_dict_append(st, "favourites_count", ixc);
 76+                st = xs_dict_append(st, "favourited",
 77+                    xs_list_in(idx, snac.md5) != -1 ? t : f);
 78+
 79+                xs_free(idx);
 80+                xs_free(ixc);
 81+                idx = object_announces(id);
 82+                ixc = xs_number_new(xs_list_len(idx));
 83 
 84-                st = xs_dict_append(st, "url",          xs_dict_get(msg, "id"));
 85+                st = xs_dict_append(st, "reblogs_count", ixc);
 86+                st = xs_dict_append(st, "reblogged",
 87+                    xs_list_in(idx, snac.md5) != -1 ? t : f);
 88+
 89+                xs_free(idx);
 90+                xs_free(ixc);
 91+                idx = object_children(id);
 92+                ixc = xs_number_new(xs_list_len(idx));
 93+
 94+                st = xs_dict_append(st, "replies_count", ixc);
 95+
 96+                st = xs_dict_append(st, "url", id);
 97 
 98                 st = xs_dict_append(st, "in_reply_to_id",         n);
 99                 st = xs_dict_append(st, "in_reply_to_account_id", n);
100                 st = xs_dict_append(st, "reblog",                 n);
101                 st = xs_dict_append(st, "poll",                   n);
102-                st = xs_dict_append(st, "card",                   ed);
103+                st = xs_dict_append(st, "card",                   n);
104+
105+                st = xs_dict_append(st, "language", n);
106+
107+                tmp = xs_dict_get(msg, "sourceContent");
108+                if (xs_is_null(tmp))
109+                    tmp = "";
110+
111+                st = xs_dict_append(st, "text", tmp);
112+
113+                tmp = xs_dict_get(msg, "updated");
114+                if (xs_is_null(tmp))
115+                    tmp = n;
116 
117-                st = xs_dict_append(st, "language",  "en");
118-                st = xs_dict_append(st, "text",      "");
119-                st = xs_dict_append(st, "edited_at", n);
120+                st = xs_dict_append(st, "edited_at", tmp);
121 
122                 out = xs_list_append(out, st);
123