mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 14:35:04 +00:00
Process Follow Group and Unfollow Group buttons.
This commit is contained in:
parent
7eef1b4b5e
commit
d32141eb22
1 changed files with 31 additions and 0 deletions
31
html.c
31
html.c
|
@ -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 *actor = xs_dict_get(p_vars, "actor");
|
||||
char *action = xs_dict_get(p_vars, "action");
|
||||
char *group = xs_dict_get(p_vars, "group");
|
||||
|
||||
if (action == NULL)
|
||||
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));
|
||||
}
|
||||
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) { /** **/
|
||||
char *actor_form = xs_dict_get(p_vars, "actor-form");
|
||||
if (actor_form != NULL) {
|
||||
|
|
Loading…
Reference in a new issue