commit 877fb07

default  ·  2024-04-11 03:12:13 +0000 UTC
parent 1a6bb79
mastoapi: 'unfavourite' and 'unreblog' actions now fully work.
2 files changed,  +17, -10
+3, -3
 1@@ -1186,11 +1186,11 @@ xs_dict *msg_repulsion(snac *user, char *id, char *type)
 2 
 3         /* copy the 'to' field */
 4         msg = xs_dict_set(msg, "to", xs_dict_get(object, "to"));
 5-
 6-        /* now we despise this */
 7-        object_unadmire(id, user->actor, *type == 'L' ? 1 : 0);
 8     }
 9 
10+    /* now we despise this */
11+    object_unadmire(id, user->actor, *type == 'L' ? 1 : 0);
12+
13     return msg;
14 }
15 
+14, -7
 1@@ -2314,11 +2314,13 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
 2                     }
 3                     else
 4                     if (strcmp(op, "unfavourite") == 0) { /** **/
 5-                        /* partial support: as the original Like message
 6-                           is not stored anywhere here, it's not possible
 7-                           to send an Undo + Like; the only thing done here
 8-                           is to delete the actor from the list of likes */
 9-                        object_unadmire(id, snac.actor, 1);
10+                        xs *n_msg = msg_repulsion(&snac, id, "Like");
11+
12+                        if (n_msg != NULL) {
13+                            enqueue_message(&snac, n_msg);
14+
15+                            out = mastoapi_status(&snac, msg);
16+                        }
17                     }
18                     else
19                     if (strcmp(op, "reblog") == 0) { /** **/
20@@ -2333,8 +2335,13 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
21                     }
22                     else
23                     if (strcmp(op, "unreblog") == 0) { /** **/
24-                        /* partial support: see comment in 'unfavourite' */
25-                        object_unadmire(id, snac.actor, 0);
26+                        xs *n_msg = msg_repulsion(&snac, id, "Announce");
27+
28+                        if (n_msg != NULL) {
29+                            enqueue_message(&snac, n_msg);
30+
31+                            out = mastoapi_status(&snac, msg);
32+                        }
33                     }
34                     else
35                     if (strcmp(op, "bookmark") == 0) { /** **/