New function enqueue_output_to_actor().

This commit is contained in:
default 2022-11-18 08:21:40 +01:00
parent e01f23cbe2
commit 654326aa8b
4 changed files with 18 additions and 6 deletions

14
data.c
View File

@ -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 */
{

5
html.c
View File

@ -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));
}

4
main.c
View File

@ -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));
}

1
snac.h
View File

@ -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);