commit 4fca7c8

default  ·  2023-04-23 06:51:02 +0000 UTC
parent 291f251
Added mastoapi unfollow.
3 files changed,  +18, -2
M data.c
M snac.h
M data.c
+1, -1
1@@ -1125,7 +1125,7 @@ int following_check(snac *snac, const char *actor)
2 }
3 
4 
5-int following_get(snac *snac, char *actor, d_char **data)
6+int following_get(snac *snac, const char *actor, d_char **data)
7 /* returns the 'Follow' object */
8 {
9     xs *fn = _following_fn(snac, actor);
+16, -0
 1@@ -1644,6 +1644,22 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
 2                 }
 3                 else
 4                 if (strcmp(opt, "unfollow") == 0) {
 5+                    if (valid_status(object_get_by_md5(md5, &actor_o))) {
 6+                        const char *actor = xs_dict_get(actor_o, "id");
 7+
 8+                        /* get the following object */
 9+                        xs *object = NULL;
10+
11+                        if (valid_status(following_get(&snac, actor, &object))) {
12+                            xs *msg = msg_undo(&snac, xs_dict_get(object, "object"));
13+
14+                            following_del(&snac, actor);
15+
16+                            enqueue_output_by_actor(&snac, msg, actor, 0);
17+
18+                            rsp = mastoapi_relationship(&snac, md5);
19+                        }
20+                    }
21                 }
22             }
23 
M snac.h
+1, -1
1@@ -115,7 +115,7 @@ d_char *local_list(snac *snac, int max);
2 int following_add(snac *snac, const char *actor, const xs_dict *msg);
3 int following_del(snac *snac, char *actor);
4 int following_check(snac *snac, const char *actor);
5-int following_get(snac *snac, char *actor, d_char **data);
6+int following_get(snac *snac, const char *actor, d_char **data);
7 d_char *following_list(snac *snac);
8 
9 void mute(snac *snac, const char *actor);