summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2022-09-29 09:11:43 +0200
committerGravatar default2022-09-29 09:11:43 +0200
commit49bca7e273640c65f9aa41309805ff3f7425123d (patch)
tree1e6e9c0b1cb5408c5eded094d4643c5274f7da09
parentTreat 410 Gone from actors specially. (diff)
downloadsnac2-49bca7e273640c65f9aa41309805ff3f7425123d.tar.gz
snac2-49bca7e273640c65f9aa41309805ff3f7425123d.tar.xz
snac2-49bca7e273640c65f9aa41309805ff3f7425123d.zip
html_entry() is built in its own string and then added.
This will be faster.
-rw-r--r--activitypub.c10
-rw-r--r--html.c16
2 files changed, 16 insertions, 10 deletions
diff --git a/activitypub.c b/activitypub.c
index 51ae6fa..cebefca 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -577,13 +577,17 @@ int process_message(snac *snac, char *msg, char *req)
577 /* bring the actor */ 577 /* bring the actor */
578 a_status = actor_request(snac, actor, &actor_o); 578 a_status = actor_request(snac, actor, &actor_o);
579 579
580 /* if it's a 410 Gone, it's a Delete crap that can be ignored */ 580 /* if the actor does not explicitly exist, discard */
581 if (a_status == 410) { 581 if (a_status == 404 || a_status == 410) {
582 snac_debug(snac, 1,
583 xs_fmt("dropping message due to actor error %s %d", actor, a_status));
584
582 return 1; 585 return 1;
583 } 586 }
584 587
585 if (!valid_status(a_status)) { 588 if (!valid_status(a_status)) {
586 snac_log(snac, 589 /* other actor download errors may need a retry */
590 snac_debug(snac, 1,
587 xs_fmt("error requesting actor %s %d -- retry later", actor, a_status)); 591 xs_fmt("error requesting actor %s %d -- retry later", actor, a_status));
588 592
589 return 0; 593 return 0;
diff --git a/html.c b/html.c
index a7ed0b4..5b336bc 100644
--- a/html.c
+++ b/html.c
@@ -368,7 +368,7 @@ d_char *html_top_controls(snac *snac, d_char *s)
368} 368}
369 369
370 370
371d_char *html_entry(snac *snac, d_char *s, char *msg, xs_set *seen, int level) 371d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int level)
372{ 372{
373 char *id = xs_dict_get(msg, "id"); 373 char *id = xs_dict_get(msg, "id");
374 char *type = xs_dict_get(msg, "type"); 374 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)
378 378
379 /* return if already seen */ 379 /* return if already seen */
380 if (xs_set_add(seen, id) == 0) 380 if (xs_set_add(seen, id) == 0)
381 return s; 381 return os;
382 382
383 if (strcmp(type, "Follow") == 0) 383 if (strcmp(type, "Follow") == 0)
384 return s; 384 return os;
385 385
386 /* bring the main actor */ 386 /* bring the main actor */
387 if ((actor = xs_dict_get(msg, "attributedTo")) == NULL) 387 if ((actor = xs_dict_get(msg, "attributedTo")) == NULL)
388 return s; 388 return os;
389 389
390 if (!valid_status(actor_get(snac, actor, &actor_o))) 390 if (!valid_status(actor_get(snac, actor, &actor_o)))
391 return s; 391 return os;
392
393 xs *s = xs_str_new(NULL);
392 394
393 /* if this is our post, add the score */ 395 /* if this is our post, add the score */
394 if (xs_startswith(id, snac->actor)) { 396 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)
422 "<a href=\"%s\">%s</a> %s</div>\n", 424 "<a href=\"%s\">%s</a> %s</div>\n",
423 xs_dict_get(actor_r, "id"), 425 xs_dict_get(actor_r, "id"),
424 name, 426 name,
425 "boosted" 427 L("boosted")
426 ); 428 );
427 429
428 s = xs_str_cat(s, s1); 430 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)
510 512
511 s = xs_str_cat(s, "</div> <!-- post or child -->\n"); 513 s = xs_str_cat(s, "</div> <!-- post or child -->\n");
512 514
513 return s; 515 return xs_str_cat(os, s);
514} 516}
515 517
516 518