Process Follow Group and Unfollow Group buttons.

This commit is contained in:
default 2023-09-06 13:58:55 +02:00
parent 7eef1b4b5e
commit d32141eb22

31
html.c
View file

@ -2282,6 +2282,7 @@ int html_post_handler(const xs_dict *req, const char *q_path,
char *id = xs_dict_get(p_vars, "id"); char *id = xs_dict_get(p_vars, "id");
char *actor = xs_dict_get(p_vars, "actor"); char *actor = xs_dict_get(p_vars, "actor");
char *action = xs_dict_get(p_vars, "action"); char *action = xs_dict_get(p_vars, "action");
char *group = xs_dict_get(p_vars, "group");
if (action == NULL) if (action == NULL)
return 404; return 404;
@ -2358,6 +2359,36 @@ int html_post_handler(const xs_dict *req, const char *q_path,
snac_log(&snac, xs_fmt("actor is not being followed %s", actor)); snac_log(&snac, xs_fmt("actor is not being followed %s", actor));
} }
else else
if (strcmp(action, L("Follow Group")) == 0) { /** **/
xs *msg = msg_follow(&snac, group);
if (msg != NULL) {
/* reload the group from the message, in may be different */
group = xs_dict_get(msg, "object");
following_add(&snac, group, msg);
enqueue_output_by_actor(&snac, msg, group, 0);
}
}
else
if (strcmp(action, L("Unfollow Group")) == 0) { /** **/
/* get the following object */
xs *object = NULL;
if (valid_status(following_get(&snac, group, &object))) {
xs *msg = msg_undo(&snac, xs_dict_get(object, "object"));
following_del(&snac, group);
enqueue_output_by_actor(&snac, msg, group, 0);
snac_log(&snac, xs_fmt("unfollowed group %s", group));
}
else
snac_log(&snac, xs_fmt("actor is not being followed %s", actor));
}
else
if (strcmp(action, L("Delete")) == 0) { /** **/ if (strcmp(action, L("Delete")) == 0) { /** **/
char *actor_form = xs_dict_get(p_vars, "actor-form"); char *actor_form = xs_dict_get(p_vars, "actor-form");
if (actor_form != NULL) { if (actor_form != NULL) {