mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
html_entry() is built in its own string and then added.
This will be faster.
This commit is contained in:
parent
c5a7a9c475
commit
49bca7e273
2 changed files with 16 additions and 10 deletions
|
@ -577,13 +577,17 @@ int process_message(snac *snac, char *msg, char *req)
|
||||||
/* bring the actor */
|
/* bring the actor */
|
||||||
a_status = actor_request(snac, actor, &actor_o);
|
a_status = actor_request(snac, actor, &actor_o);
|
||||||
|
|
||||||
/* if it's a 410 Gone, it's a Delete crap that can be ignored */
|
/* if the actor does not explicitly exist, discard */
|
||||||
if (a_status == 410) {
|
if (a_status == 404 || a_status == 410) {
|
||||||
|
snac_debug(snac, 1,
|
||||||
|
xs_fmt("dropping message due to actor error %s %d", actor, a_status));
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!valid_status(a_status)) {
|
if (!valid_status(a_status)) {
|
||||||
snac_log(snac,
|
/* other actor download errors may need a retry */
|
||||||
|
snac_debug(snac, 1,
|
||||||
xs_fmt("error requesting actor %s %d -- retry later", actor, a_status));
|
xs_fmt("error requesting actor %s %d -- retry later", actor, a_status));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
16
html.c
16
html.c
|
@ -368,7 +368,7 @@ d_char *html_top_controls(snac *snac, d_char *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
d_char *html_entry(snac *snac, d_char *s, char *msg, xs_set *seen, int level)
|
d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int level)
|
||||||
{
|
{
|
||||||
char *id = xs_dict_get(msg, "id");
|
char *id = xs_dict_get(msg, "id");
|
||||||
char *type = xs_dict_get(msg, "type");
|
char *type = xs_dict_get(msg, "type");
|
||||||
|
@ -378,17 +378,19 @@ d_char *html_entry(snac *snac, d_char *s, char *msg, xs_set *seen, int level)
|
||||||
|
|
||||||
/* return if already seen */
|
/* return if already seen */
|
||||||
if (xs_set_add(seen, id) == 0)
|
if (xs_set_add(seen, id) == 0)
|
||||||
return s;
|
return os;
|
||||||
|
|
||||||
if (strcmp(type, "Follow") == 0)
|
if (strcmp(type, "Follow") == 0)
|
||||||
return s;
|
return os;
|
||||||
|
|
||||||
/* bring the main actor */
|
/* bring the main actor */
|
||||||
if ((actor = xs_dict_get(msg, "attributedTo")) == NULL)
|
if ((actor = xs_dict_get(msg, "attributedTo")) == NULL)
|
||||||
return s;
|
return os;
|
||||||
|
|
||||||
if (!valid_status(actor_get(snac, actor, &actor_o)))
|
if (!valid_status(actor_get(snac, actor, &actor_o)))
|
||||||
return s;
|
return os;
|
||||||
|
|
||||||
|
xs *s = xs_str_new(NULL);
|
||||||
|
|
||||||
/* if this is our post, add the score */
|
/* if this is our post, add the score */
|
||||||
if (xs_startswith(id, snac->actor)) {
|
if (xs_startswith(id, snac->actor)) {
|
||||||
|
@ -422,7 +424,7 @@ d_char *html_entry(snac *snac, d_char *s, char *msg, xs_set *seen, int level)
|
||||||
"<a href=\"%s\">%s</a> %s</div>\n",
|
"<a href=\"%s\">%s</a> %s</div>\n",
|
||||||
xs_dict_get(actor_r, "id"),
|
xs_dict_get(actor_r, "id"),
|
||||||
name,
|
name,
|
||||||
"boosted"
|
L("boosted")
|
||||||
);
|
);
|
||||||
|
|
||||||
s = xs_str_cat(s, s1);
|
s = xs_str_cat(s, s1);
|
||||||
|
@ -510,7 +512,7 @@ d_char *html_entry(snac *snac, d_char *s, char *msg, xs_set *seen, int level)
|
||||||
|
|
||||||
s = xs_str_cat(s, "</div> <!-- post or child -->\n");
|
s = xs_str_cat(s, "</div> <!-- post or child -->\n");
|
||||||
|
|
||||||
return s;
|
return xs_str_cat(os, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue