process_input_message() returns -1 on errors.

This commit is contained in:
default 2023-12-10 10:00:17 +01:00
parent d7fe3ba615
commit 95ccff541c

View file

@ -1468,13 +1468,17 @@ int update_question(snac *user, const char *id)
int process_input_message(snac *snac, xs_dict *msg, xs_dict *req) int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
/* processes an ActivityPub message from the input queue */ /* processes an ActivityPub message from the input queue */
{ {
/* actor and type exist, were checked previously */
char *actor = xs_dict_get(msg, "actor"); char *actor = xs_dict_get(msg, "actor");
char *type = xs_dict_get(msg, "type"); char *type = xs_dict_get(msg, "type");
xs *actor_o = NULL; xs *actor_o = NULL;
int a_status; int a_status;
int do_notify = 0; int do_notify = 0;
if (xs_is_null(actor) || *actor == '\0') {
snac_debug(snac, 0, xs_fmt("malformed message (bad actor)"));
return -1;
}
/* question votes may not have a type */ /* question votes may not have a type */
if (xs_is_null(type)) if (xs_is_null(type))
type = "Note"; type = "Note";
@ -1482,12 +1486,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
/* reject uninteresting messages right now */ /* reject uninteresting messages right now */
if (strcmp(type, "Add") == 0) { if (strcmp(type, "Add") == 0) {
snac_debug(snac, 0, xs_fmt("Ignored message of type '%s'", type)); snac_debug(snac, 0, xs_fmt("Ignored message of type '%s'", type));
return 1; return -1;
}
if (xs_is_null(actor)) {
snac_debug(snac, 0, xs_fmt("malformed message"));
return 1;
} }
char *object, *utype; char *object, *utype;
@ -1523,7 +1522,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
snac_debug(snac, 1, snac_debug(snac, 1,
xs_fmt("dropping message due to actor error %s %d", actor, a_status)); xs_fmt("dropping message due to actor error %s %d", actor, a_status));
return 1; return -1;
} }
if (!valid_status(a_status)) { if (!valid_status(a_status)) {
@ -1542,7 +1541,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
srv_archive_error("check_signature", sig_err, req, msg); srv_archive_error("check_signature", sig_err, req, msg);
return 1; return -1;
} }
if (strcmp(type, "Follow") == 0) { /** **/ if (strcmp(type, "Follow") == 0) { /** **/