summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authorGravatar default2023-04-10 08:52:04 +0200
committerGravatar default2023-04-10 08:52:04 +0200
commit578d70ddc01f05a3564fb3028d2e3cfc8da5cc64 (patch)
tree09b73f26beb89385b932d89d46ecd6992e6cce8d /mastoapi.c
parentLimit the number of entries returned using the max_id. (diff)
downloadsnac2-578d70ddc01f05a3564fb3028d2e3cfc8da5cc64.tar.gz
snac2-578d70ddc01f05a3564fb3028d2e3cfc8da5cc64.tar.xz
snac2-578d70ddc01f05a3564fb3028d2e3cfc8da5cc64.zip
More work in status entries.
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c76
1 files changed, 58 insertions, 18 deletions
diff --git a/mastoapi.c b/mastoapi.c
index c745c33..3b0ccbd 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -410,8 +410,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
410 /* the private timeline */ 410 /* the private timeline */
411 if (logged_in) { 411 if (logged_in) {
412 const char *max_id = xs_dict_get(args, "max_id"); 412 const char *max_id = xs_dict_get(args, "max_id");
413 const char *since_id = xs_dict_get(args, "since_id"); 413// const char *since_id = xs_dict_get(args, "since_id");
414 const char *min_id = xs_dict_get(args, "min_id"); 414// const char *min_id = xs_dict_get(args, "min_id");
415 const char *limit_s = xs_dict_get(args, "limit"); 415 const char *limit_s = xs_dict_get(args, "limit");
416 int limit = 20; 416 int limit = 20;
417 int cnt = 0; 417 int cnt = 0;
@@ -419,8 +419,9 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
419 if (!xs_is_null(limit_s)) 419 if (!xs_is_null(limit_s))
420 limit = atoi(limit_s); 420 limit = atoi(limit_s);
421 421
422 xs *out = xs_list_new();
423 xs *timeline = timeline_list(&snac, "private", 0, XS_ALL); 422 xs *timeline = timeline_list(&snac, "private", 0, XS_ALL);
423
424 xs *out = xs_list_new();
424 xs_list *p = timeline; 425 xs_list *p = timeline;
425 xs_str *v; 426 xs_str *v;
426 427
@@ -476,17 +477,20 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
476 477
477 acct = xs_dict_append(acct, "avatar", avatar); 478 acct = xs_dict_append(acct, "avatar", avatar);
478 479
479 xs *f = xs_val_new(XSTYPE_FALSE); 480 xs *f = xs_val_new(XSTYPE_FALSE);
480 xs *t = xs_val_new(XSTYPE_TRUE); 481 xs *t = xs_val_new(XSTYPE_TRUE);
481 xs *n = xs_val_new(XSTYPE_NULL); 482 xs *n = xs_val_new(XSTYPE_NULL);
482 xs *el = xs_list_new(); 483 xs *el = xs_list_new();
483 xs *ed = xs_dict_new(); 484 xs *idx = NULL;
485 xs *ixc = NULL;
486
484 char *tmp; 487 char *tmp;
488 id = xs_dict_get(msg, "id");
485 489
486 xs *st = xs_dict_new(); 490 xs *st = xs_dict_new();
487 491
488 st = xs_dict_append(st, "id", v); 492 st = xs_dict_append(st, "id", v);
489 st = xs_dict_append(st, "uri", xs_dict_get(msg, "id")); 493 st = xs_dict_append(st, "uri", id);
490 st = xs_dict_append(st, "created_at", xs_dict_get(msg, "published")); 494 st = xs_dict_append(st, "created_at", xs_dict_get(msg, "published"));
491 st = xs_dict_append(st, "account", acct); 495 st = xs_dict_append(st, "account", acct);
492 st = xs_dict_append(st, "content", xs_dict_get(msg, "content")); 496 st = xs_dict_append(st, "content", xs_dict_get(msg, "content"));
@@ -497,28 +501,64 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
497 tmp = f; 501 tmp = f;
498 502
499 st = xs_dict_append(st, "sensitive", tmp); 503 st = xs_dict_append(st, "sensitive", tmp);
500 st = xs_dict_append(st, "spoiler_text", ""); 504
505 tmp = xs_dict_get(msg, "summary");
506 if (xs_is_null(tmp))
507 tmp = "";
508
509 st = xs_dict_append(st, "spoiler_text", tmp);
501 510
502 st = xs_dict_append(st, "media_attachments", el); 511 st = xs_dict_append(st, "media_attachments", el);
503 st = xs_dict_append(st, "mentions", el); 512 st = xs_dict_append(st, "mentions", el);
504 st = xs_dict_append(st, "tags", el); 513 st = xs_dict_append(st, "tags", el);
505 st = xs_dict_append(st, "emojis", el); 514 st = xs_dict_append(st, "emojis", el);
506 515
507 st = xs_dict_append(st, "reblogs_count", xs_number_new(0)); 516 xs_free(idx);
508 st = xs_dict_append(st, "favourites_count", xs_number_new(0)); 517 xs_free(ixc);
509 st = xs_dict_append(st, "replies_count", xs_number_new(0)); 518 idx = object_likes(id);
519 ixc = xs_number_new(xs_list_len(idx));
520
521 st = xs_dict_append(st, "favourites_count", ixc);
522 st = xs_dict_append(st, "favourited",
523 xs_list_in(idx, snac.md5) != -1 ? t : f);
524
525 xs_free(idx);
526 xs_free(ixc);
527 idx = object_announces(id);
528 ixc = xs_number_new(xs_list_len(idx));
510 529
511 st = xs_dict_append(st, "url", xs_dict_get(msg, "id")); 530 st = xs_dict_append(st, "reblogs_count", ixc);
531 st = xs_dict_append(st, "reblogged",
532 xs_list_in(idx, snac.md5) != -1 ? t : f);
533
534 xs_free(idx);
535 xs_free(ixc);
536 idx = object_children(id);
537 ixc = xs_number_new(xs_list_len(idx));
538
539 st = xs_dict_append(st, "replies_count", ixc);
540
541 st = xs_dict_append(st, "url", id);
512 542
513 st = xs_dict_append(st, "in_reply_to_id", n); 543 st = xs_dict_append(st, "in_reply_to_id", n);
514 st = xs_dict_append(st, "in_reply_to_account_id", n); 544 st = xs_dict_append(st, "in_reply_to_account_id", n);
515 st = xs_dict_append(st, "reblog", n); 545 st = xs_dict_append(st, "reblog", n);
516 st = xs_dict_append(st, "poll", n); 546 st = xs_dict_append(st, "poll", n);
517 st = xs_dict_append(st, "card", ed); 547 st = xs_dict_append(st, "card", n);
548
549 st = xs_dict_append(st, "language", n);
550
551 tmp = xs_dict_get(msg, "sourceContent");
552 if (xs_is_null(tmp))
553 tmp = "";
554
555 st = xs_dict_append(st, "text", tmp);
556
557 tmp = xs_dict_get(msg, "updated");
558 if (xs_is_null(tmp))
559 tmp = n;
518 560
519 st = xs_dict_append(st, "language", "en"); 561 st = xs_dict_append(st, "edited_at", tmp);
520 st = xs_dict_append(st, "text", "");
521 st = xs_dict_append(st, "edited_at", n);
522 562
523 out = xs_list_append(out, st); 563 out = xs_list_append(out, st);
524 564