diff options
| author | 2022-12-03 18:08:44 +0100 | |
|---|---|---|
| committer | 2022-12-03 18:08:44 +0100 | |
| commit | f205d206883b62bcee0d34f633654e0c24057a86 (patch) | |
| tree | 0f5f5124384f1eea8cea5f78d3a12eebf16ba0d7 /html.c | |
| parent | Upgraded local/ to public/. (diff) | |
| download | snac2-f205d206883b62bcee0d34f633654e0c24057a86.tar.gz snac2-f205d206883b62bcee0d34f633654e0c24057a86.tar.xz snac2-f205d206883b62bcee0d34f633654e0c24057a86.zip | |
Always show who boosted something, not only when it's on level 0.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 85 |
1 files changed, 42 insertions, 43 deletions
| @@ -548,57 +548,43 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, int | |||
| 548 | s = xs_str_cat(s, s1); | 548 | s = xs_str_cat(s, s1); |
| 549 | } | 549 | } |
| 550 | 550 | ||
| 551 | if (level == 0) { | 551 | if (level == 0) |
| 552 | s = xs_str_cat(s, "<div class=\"snac-post\">\n"); | 552 | s = xs_str_cat(s, "<div class=\"snac-post\">\n"); |
| 553 | else | ||
| 554 | s = xs_str_cat(s, "<div class=\"snac-child\">\n"); | ||
| 553 | 555 | ||
| 554 | if (boosts == NULL) | 556 | if (boosts == NULL) |
| 555 | boosts = object_announces(id); | 557 | boosts = object_announces(id); |
| 556 | |||
| 557 | if (xs_list_len(boosts)) { | ||
| 558 | /* if somebody boosted this, show as origin */ | ||
| 559 | char *p = xs_list_get(boosts, -1); | ||
| 560 | xs *actor_r = NULL; | ||
| 561 | |||
| 562 | if (xs_list_in(boosts, snac->md5) != -1) { | ||
| 563 | /* we boosted this */ | ||
| 564 | xs *s1 = xs_fmt( | ||
| 565 | "<div class=\"snac-origin\">" | ||
| 566 | "<a href=\"%s\">%s</a> %s</a></div>", | ||
| 567 | snac->actor, xs_dict_get(snac->config, "name"), L("boosted") | ||
| 568 | ); | ||
| 569 | |||
| 570 | s = xs_str_cat(s, s1); | ||
| 571 | } | ||
| 572 | else | ||
| 573 | if (valid_status(object_get_by_md5(p, &actor_r, NULL))) { | ||
| 574 | char *name; | ||
| 575 | 558 | ||
| 576 | if ((name = xs_dict_get(actor_r, "name")) == NULL) | 559 | if (xs_list_len(boosts)) { |
| 577 | name = xs_dict_get(actor_r, "preferredUsername"); | 560 | /* if somebody boosted this, show as origin */ |
| 561 | char *p = xs_list_get(boosts, -1); | ||
| 562 | xs *actor_r = NULL; | ||
| 578 | 563 | ||
| 579 | if (!xs_is_null(name)) { | 564 | if (xs_list_in(boosts, snac->md5) != -1) { |
| 580 | xs *s1 = xs_fmt( | 565 | /* we boosted this */ |
| 581 | "<div class=\"snac-origin\">" | 566 | xs *s1 = xs_fmt( |
| 582 | "<a href=\"%s\">%s</a> %s</div>\n", | 567 | "<div class=\"snac-origin\">" |
| 583 | xs_dict_get(actor_r, "id"), | 568 | "<a href=\"%s\">%s</a> %s</a></div>", |
| 584 | name, | 569 | snac->actor, xs_dict_get(snac->config, "name"), L("boosted") |
| 585 | L("boosted") | 570 | ); |
| 586 | ); | ||
| 587 | 571 | ||
| 588 | s = xs_str_cat(s, s1); | 572 | s = xs_str_cat(s, s1); |
| 589 | } | ||
| 590 | } | ||
| 591 | } | 573 | } |
| 592 | else | 574 | else |
| 593 | if (strcmp(type, "Note") == 0) { | 575 | if (valid_status(object_get_by_md5(p, &actor_r, NULL))) { |
| 594 | /* is the parent not here? */ | 576 | char *name; |
| 595 | char *parent = xs_dict_get(msg, "inReplyTo"); | ||
| 596 | 577 | ||
| 597 | if (!xs_is_null(parent) && *parent && !object_here(parent)) { | 578 | if ((name = xs_dict_get(actor_r, "name")) == NULL) |
| 579 | name = xs_dict_get(actor_r, "preferredUsername"); | ||
| 580 | |||
| 581 | if (!xs_is_null(name)) { | ||
| 598 | xs *s1 = xs_fmt( | 582 | xs *s1 = xs_fmt( |
| 599 | "<div class=\"snac-origin\">%s " | 583 | "<div class=\"snac-origin\">" |
| 600 | "<a href=\"%s\">»</a></div>\n", | 584 | "<a href=\"%s\">%s</a> %s</div>\n", |
| 601 | L("in reply to"), parent | 585 | xs_dict_get(actor_r, "id"), |
| 586 | name, | ||
| 587 | L("boosted") | ||
| 602 | ); | 588 | ); |
| 603 | 589 | ||
| 604 | s = xs_str_cat(s, s1); | 590 | s = xs_str_cat(s, s1); |
| @@ -606,7 +592,20 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, int | |||
| 606 | } | 592 | } |
| 607 | } | 593 | } |
| 608 | else | 594 | else |
| 609 | s = xs_str_cat(s, "<div class=\"snac-child\">\n"); | 595 | if (strcmp(type, "Note") == 0) { |
| 596 | /* is the parent not here? */ | ||
| 597 | char *parent = xs_dict_get(msg, "inReplyTo"); | ||
| 598 | |||
| 599 | if (!xs_is_null(parent) && *parent && !object_here(parent)) { | ||
| 600 | xs *s1 = xs_fmt( | ||
| 601 | "<div class=\"snac-origin\">%s " | ||
| 602 | "<a href=\"%s\">»</a></div>\n", | ||
| 603 | L("in reply to"), parent | ||
| 604 | ); | ||
| 605 | |||
| 606 | s = xs_str_cat(s, s1); | ||
| 607 | } | ||
| 608 | } | ||
| 610 | 609 | ||
| 611 | s = html_msg_icon(snac, s, msg); | 610 | s = html_msg_icon(snac, s, msg); |
| 612 | 611 | ||