Call process_input_message() from the shared-inbox input.

This way, some garbage like unrequested Deletes from Mastodon
and other transient errors (like unaccessible authors) can be
short-circuited before propagating the message to the users.
This commit is contained in:
default 2023-12-11 17:59:48 +01:00
parent b1ecaba803
commit 888a79e58a

View file

@ -2052,10 +2052,30 @@ void process_queue_item(xs_dict *q_item)
} }
else else
if (strcmp(type, "input") == 0) { if (strcmp(type, "input") == 0) {
xs_dict *msg = xs_dict_get(q_item, "message");
xs_dict *req = xs_dict_get(q_item, "req");
int retries = xs_number_get(xs_dict_get(q_item, "retries"));
/* do some instance-level checks */
int r = process_input_message(NULL, msg, req);
if (r == 0) {
/* transient error? retry */
int queue_retry_max = xs_number_get(xs_dict_get(srv_config, "queue_retry_max"));
if (retries > queue_retry_max)
srv_log(xs_fmt("shared input giving up"));
else {
/* reenqueue */
enqueue_shared_input(msg, req, retries + 1);
srv_log(xs_fmt("shared input requeue #%d", retries + 1));
}
}
else
if (r == 2) {
/* redistribute the input message to all users */ /* redistribute the input message to all users */
char *ntid = xs_dict_get(q_item, "ntid"); char *ntid = xs_dict_get(q_item, "ntid");
xs *tmpfn = xs_fmt("%s/tmp/%s.json", srv_basedir, ntid); xs *tmpfn = xs_fmt("%s/tmp/%s.json", srv_basedir, ntid);
xs_dict *msg = xs_dict_get(q_item, "message");
FILE *f; FILE *f;
if ((f = fopen(tmpfn, "w")) != NULL) { if ((f = fopen(tmpfn, "w")) != NULL) {
@ -2092,6 +2112,7 @@ void process_queue_item(xs_dict *q_item)
if (cnt == 0) if (cnt == 0)
srv_debug(1, xs_fmt("no valid recipients for %s", tmpfn)); srv_debug(1, xs_fmt("no valid recipients for %s", tmpfn));
} }
}
else else
srv_log(xs_fmt("unexpected q_item type '%s'", type)); srv_log(xs_fmt("unexpected q_item type '%s'", type));
} }