diff --git a/data.c b/data.c index 2fbb49e..3f0ccf7 100644 --- a/data.c +++ b/data.c @@ -1064,7 +1064,7 @@ void enqueue_input(snac *snac, char *msg, char *req, int retries) void enqueue_output(snac *snac, char *msg, char *inbox, int retries) -/* enqueues an output message for an actor */ +/* enqueues an output message to an inbox */ { if (xs_startswith(inbox, snac->actor)) { snac_debug(snac, 1, xs_str_new("refusing enqueue to myself")); @@ -1088,6 +1088,18 @@ void enqueue_output(snac *snac, char *msg, char *inbox, int retries) } +void enqueue_output_by_actor(snac *snac, char *msg, char *actor, int retries) +/* enqueues an output message for an actor */ +{ + xs *inbox = get_actor_inbox(snac, actor); + + if (!xs_is_null(inbox)) + enqueue_output(snac, msg, inbox, retries); + else + snac_log(snac, xs_fmt("enqueue_output_by_actor cannot get inbox %s", actor)); +} + + void enqueue_email(snac *snac, char *msg, int retries) /* enqueues an email message to be sent */ { diff --git a/html.c b/html.c index 1b227fa..b48eae4 100644 --- a/html.c +++ b/html.c @@ -1215,11 +1215,10 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, if (msg != NULL) { /* reload the actor from the message, in may be different */ actor = xs_dict_get(msg, "object"); - xs *inbox = get_actor_inbox(&snac, actor); following_add(&snac, actor, msg); - enqueue_output(&snac, msg, inbox, 0); + enqueue_output_by_actor(&snac, msg, actor, 0); } } else @@ -1232,7 +1231,7 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, following_del(&snac, actor); - enqueue_output(&snac, msg, actor, 0); + enqueue_output_by_actor(&snac, msg, actor, 0); snac_log(&snac, xs_fmt("unfollowed actor %s", actor)); } diff --git a/main.c b/main.c index befbd32..8e3dbd2 100644 --- a/main.c +++ b/main.c @@ -178,7 +178,7 @@ int main(int argc, char *argv[]) following_add(&snac, actor, msg); - enqueue_output(&snac, msg, actor, 0); + enqueue_output_by_actor(&snac, msg, actor, 0); if (dbglevel) { xs *j = xs_json_dumps_pp(msg, 4); @@ -197,7 +197,7 @@ int main(int argc, char *argv[]) following_del(&snac, url); - enqueue_output(&snac, msg, url, 0); + enqueue_output_by_actor(&snac, msg, url, 0); snac_log(&snac, xs_fmt("unfollowed actor %s", url)); } diff --git a/snac.h b/snac.h index cfb694a..852e40b 100644 --- a/snac.h +++ b/snac.h @@ -93,6 +93,7 @@ d_char *history_list(snac *snac); void enqueue_input(snac *snac, char *msg, char *req, int retries); void enqueue_output(snac *snac, char *msg, char *inbox, int retries); +void enqueue_output_by_actor(snac *snac, char *msg, char *actor, int retries); void enqueue_email(snac *snac, char *msg, int retries); d_char *queue(snac *snac);