Browse Source

Some timeline fixes.

default 3 years ago
parent
commit
862dafd066
1 changed files with 13 additions and 4 deletions
  1. 13 4
      mastoapi.c

+ 13 - 4
mastoapi.c

@@ -443,12 +443,15 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
             const char *since_id = xs_dict_get(args, "since_id");
             const char *since_id = xs_dict_get(args, "since_id");
 //            const char *min_id   = xs_dict_get(args, "min_id");
 //            const char *min_id   = xs_dict_get(args, "min_id");
             const char *limit_s  = xs_dict_get(args, "limit");
             const char *limit_s  = xs_dict_get(args, "limit");
-            int limit = 20;
-            int cnt = 0;
+            int limit = 0;
+            int cnt   = 0;
 
 
             if (!xs_is_null(limit_s))
             if (!xs_is_null(limit_s))
                 limit = atoi(limit_s);
                 limit = atoi(limit_s);
 
 
+            if (limit == 0)
+                limit = 20;
+
             xs *timeline = timeline_simple_list(&snac, "private", 0, XS_ALL);
             xs *timeline = timeline_simple_list(&snac, "private", 0, XS_ALL);
 
 
             xs *out      = xs_list_new();
             xs *out      = xs_list_new();
@@ -495,13 +498,17 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
                 if (xs_is_null(display_name) || *display_name == '\0')
                 if (xs_is_null(display_name) || *display_name == '\0')
                     display_name = xs_dict_get(actor, "preferredUsername");
                     display_name = xs_dict_get(actor, "preferredUsername");
 
 
-                const char *id = xs_dict_get(actor, "id");
+                const char *id  = xs_dict_get(actor, "id");
+                const char *pub = xs_dict_get(actor, "published");
                 xs *acct_md5 = xs_md5_hex(id, strlen(id));
                 xs *acct_md5 = xs_md5_hex(id, strlen(id));
                 acct = xs_dict_append(acct, "id",           acct_md5);
                 acct = xs_dict_append(acct, "id",           acct_md5);
                 acct = xs_dict_append(acct, "username",     xs_dict_get(actor, "preferredUsername"));
                 acct = xs_dict_append(acct, "username",     xs_dict_get(actor, "preferredUsername"));
                 acct = xs_dict_append(acct, "acct",         xs_dict_get(actor, "preferredUsername"));
                 acct = xs_dict_append(acct, "acct",         xs_dict_get(actor, "preferredUsername"));
                 acct = xs_dict_append(acct, "display_name", display_name);
                 acct = xs_dict_append(acct, "display_name", display_name);
-                acct = xs_dict_append(acct, "created_at",   xs_dict_get(actor, "published"));
+
+                if (pub)
+                    acct = xs_dict_append(acct, "created_at", pub);
+
                 acct = xs_dict_append(acct, "note",         xs_dict_get(actor, "summary"));
                 acct = xs_dict_append(acct, "note",         xs_dict_get(actor, "summary"));
                 acct = xs_dict_append(acct, "url",          id);
                 acct = xs_dict_append(acct, "url",          id);
 
 
@@ -624,6 +631,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
             *body  = xs_json_dumps_pp(out, 4);
             *body  = xs_json_dumps_pp(out, 4);
             *ctype = "application/json";
             *ctype = "application/json";
             status = 200;
             status = 200;
+
+//            printf("%s\n", *body);
         }
         }
         else {
         else {
             status = 401; // unauthorized
             status = 401; // unauthorized