mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 22:45:05 +00:00
New function enqueue_output_to_actor().
This commit is contained in:
parent
e01f23cbe2
commit
654326aa8b
4 changed files with 18 additions and 6 deletions
14
data.c
14
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)
|
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)) {
|
if (xs_startswith(inbox, snac->actor)) {
|
||||||
snac_debug(snac, 1, xs_str_new("refusing enqueue to myself"));
|
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)
|
void enqueue_email(snac *snac, char *msg, int retries)
|
||||||
/* enqueues an email message to be sent */
|
/* enqueues an email message to be sent */
|
||||||
{
|
{
|
||||||
|
|
5
html.c
5
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) {
|
if (msg != NULL) {
|
||||||
/* reload the actor from the message, in may be different */
|
/* reload the actor from the message, in may be different */
|
||||||
actor = xs_dict_get(msg, "object");
|
actor = xs_dict_get(msg, "object");
|
||||||
xs *inbox = get_actor_inbox(&snac, actor);
|
|
||||||
|
|
||||||
following_add(&snac, actor, msg);
|
following_add(&snac, actor, msg);
|
||||||
|
|
||||||
enqueue_output(&snac, msg, inbox, 0);
|
enqueue_output_by_actor(&snac, msg, actor, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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);
|
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));
|
snac_log(&snac, xs_fmt("unfollowed actor %s", actor));
|
||||||
}
|
}
|
||||||
|
|
4
main.c
4
main.c
|
@ -178,7 +178,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
following_add(&snac, actor, msg);
|
following_add(&snac, actor, msg);
|
||||||
|
|
||||||
enqueue_output(&snac, msg, actor, 0);
|
enqueue_output_by_actor(&snac, msg, actor, 0);
|
||||||
|
|
||||||
if (dbglevel) {
|
if (dbglevel) {
|
||||||
xs *j = xs_json_dumps_pp(msg, 4);
|
xs *j = xs_json_dumps_pp(msg, 4);
|
||||||
|
@ -197,7 +197,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
following_del(&snac, url);
|
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));
|
snac_log(&snac, xs_fmt("unfollowed actor %s", url));
|
||||||
}
|
}
|
||||||
|
|
1
snac.h
1
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_input(snac *snac, char *msg, char *req, int retries);
|
||||||
void enqueue_output(snac *snac, char *msg, char *inbox, 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);
|
void enqueue_email(snac *snac, char *msg, int retries);
|
||||||
|
|
||||||
d_char *queue(snac *snac);
|
d_char *queue(snac *snac);
|
||||||
|
|
Loading…
Reference in a new issue