commit 1a6bb79
default
·
2024-04-10 16:27:17 +0000 UTC
parent a6958d6
New function msg_repulsion.
3 files changed,
+42,
-0
+27,
-0
1@@ -1168,6 +1168,33 @@ xs_dict *msg_admiration(snac *snac, char *object, char *type)
2 }
3
4
5+xs_dict *msg_repulsion(snac *user, char *id, char *type)
6+/* creates an Undo + admiration message */
7+{
8+ xs *a_msg = NULL;
9+ xs_dict *msg = NULL;
10+
11+ if (valid_status(object_get(id, &a_msg))) {
12+ /* create a clone of the original admiration message */
13+ xs *object = msg_admiration(user, id, type);
14+
15+ /* delete the published date */
16+ object = xs_dict_del(object, "published");
17+
18+ /* create an undo message for this object */
19+ msg = msg_undo(user, object);
20+
21+ /* copy the 'to' field */
22+ msg = xs_dict_set(msg, "to", xs_dict_get(object, "to"));
23+
24+ /* now we despise this */
25+ object_unadmire(id, user->actor, *type == 'L' ? 1 : 0);
26+ }
27+
28+ return msg;
29+}
30+
31+
32 xs_dict *msg_actor(snac *snac)
33 /* create a Person message for this actor */
34 {
M
main.c
+14,
-0
1@@ -295,6 +295,20 @@ int main(int argc, char *argv[])
2 return 0;
3 }
4
5+ if (strcmp(cmd, "unboost") == 0) { /** **/
6+ xs *msg = msg_repulsion(&snac, url, "Announce");
7+
8+ if (msg != NULL) {
9+ enqueue_message(&snac, msg);
10+
11+ if (dbglevel) {
12+ xs_json_dump(msg, 4, stdout);
13+ }
14+ }
15+
16+ return 0;
17+ }
18+
19 if (strcmp(cmd, "follow") == 0) { /** **/
20 xs *msg = msg_follow(&snac, url);
21
M
snac.h
+1,
-0
1@@ -264,6 +264,7 @@ char *get_atto(const xs_dict *msg);
2 xs_list *get_attachments(const xs_dict *msg);
3
4 xs_dict *msg_admiration(snac *snac, char *object, char *type);
5+xs_dict *msg_repulsion(snac *user, char *id, char *type);
6 xs_dict *msg_create(snac *snac, const xs_dict *object);
7 xs_dict *msg_follow(snac *snac, const char *actor);
8