diff options
| -rw-r--r-- | activitypub.c | 27 | ||||
| -rw-r--r-- | main.c | 14 | ||||
| -rw-r--r-- | snac.h | 1 |
3 files changed, 42 insertions, 0 deletions
diff --git a/activitypub.c b/activitypub.c index c88b0ce..afbe7af 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -1168,6 +1168,33 @@ xs_dict *msg_admiration(snac *snac, char *object, char *type) | |||
| 1168 | } | 1168 | } |
| 1169 | 1169 | ||
| 1170 | 1170 | ||
| 1171 | xs_dict *msg_repulsion(snac *user, char *id, char *type) | ||
| 1172 | /* creates an Undo + admiration message */ | ||
| 1173 | { | ||
| 1174 | xs *a_msg = NULL; | ||
| 1175 | xs_dict *msg = NULL; | ||
| 1176 | |||
| 1177 | if (valid_status(object_get(id, &a_msg))) { | ||
| 1178 | /* create a clone of the original admiration message */ | ||
| 1179 | xs *object = msg_admiration(user, id, type); | ||
| 1180 | |||
| 1181 | /* delete the published date */ | ||
| 1182 | object = xs_dict_del(object, "published"); | ||
| 1183 | |||
| 1184 | /* create an undo message for this object */ | ||
| 1185 | msg = msg_undo(user, object); | ||
| 1186 | |||
| 1187 | /* copy the 'to' field */ | ||
| 1188 | msg = xs_dict_set(msg, "to", xs_dict_get(object, "to")); | ||
| 1189 | |||
| 1190 | /* now we despise this */ | ||
| 1191 | object_unadmire(id, user->actor, *type == 'L' ? 1 : 0); | ||
| 1192 | } | ||
| 1193 | |||
| 1194 | return msg; | ||
| 1195 | } | ||
| 1196 | |||
| 1197 | |||
| 1171 | xs_dict *msg_actor(snac *snac) | 1198 | xs_dict *msg_actor(snac *snac) |
| 1172 | /* create a Person message for this actor */ | 1199 | /* create a Person message for this actor */ |
| 1173 | { | 1200 | { |
| @@ -295,6 +295,20 @@ int main(int argc, char *argv[]) | |||
| 295 | return 0; | 295 | return 0; |
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | if (strcmp(cmd, "unboost") == 0) { /** **/ | ||
| 299 | xs *msg = msg_repulsion(&snac, url, "Announce"); | ||
| 300 | |||
| 301 | if (msg != NULL) { | ||
| 302 | enqueue_message(&snac, msg); | ||
| 303 | |||
| 304 | if (dbglevel) { | ||
| 305 | xs_json_dump(msg, 4, stdout); | ||
| 306 | } | ||
| 307 | } | ||
| 308 | |||
| 309 | return 0; | ||
| 310 | } | ||
| 311 | |||
| 298 | if (strcmp(cmd, "follow") == 0) { /** **/ | 312 | if (strcmp(cmd, "follow") == 0) { /** **/ |
| 299 | xs *msg = msg_follow(&snac, url); | 313 | xs *msg = msg_follow(&snac, url); |
| 300 | 314 | ||
| @@ -264,6 +264,7 @@ char *get_atto(const xs_dict *msg); | |||
| 264 | xs_list *get_attachments(const xs_dict *msg); | 264 | xs_list *get_attachments(const xs_dict *msg); |
| 265 | 265 | ||
| 266 | xs_dict *msg_admiration(snac *snac, char *object, char *type); | 266 | xs_dict *msg_admiration(snac *snac, char *object, char *type); |
| 267 | xs_dict *msg_repulsion(snac *user, char *id, char *type); | ||
| 267 | xs_dict *msg_create(snac *snac, const xs_dict *object); | 268 | xs_dict *msg_create(snac *snac, const xs_dict *object); |
| 268 | xs_dict *msg_follow(snac *snac, const char *actor); | 269 | xs_dict *msg_follow(snac *snac, const char *actor); |
| 269 | 270 | ||