mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
New function msg_repulsion.
This commit is contained in:
parent
a6958d6161
commit
1a6bb79921
3 changed files with 42 additions and 0 deletions
|
@ -1168,6 +1168,33 @@ xs_dict *msg_admiration(snac *snac, char *object, char *type)
|
|||
}
|
||||
|
||||
|
||||
xs_dict *msg_repulsion(snac *user, char *id, char *type)
|
||||
/* creates an Undo + admiration message */
|
||||
{
|
||||
xs *a_msg = NULL;
|
||||
xs_dict *msg = NULL;
|
||||
|
||||
if (valid_status(object_get(id, &a_msg))) {
|
||||
/* create a clone of the original admiration message */
|
||||
xs *object = msg_admiration(user, id, type);
|
||||
|
||||
/* delete the published date */
|
||||
object = xs_dict_del(object, "published");
|
||||
|
||||
/* create an undo message for this object */
|
||||
msg = msg_undo(user, object);
|
||||
|
||||
/* copy the 'to' field */
|
||||
msg = xs_dict_set(msg, "to", xs_dict_get(object, "to"));
|
||||
|
||||
/* now we despise this */
|
||||
object_unadmire(id, user->actor, *type == 'L' ? 1 : 0);
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
xs_dict *msg_actor(snac *snac)
|
||||
/* create a Person message for this actor */
|
||||
{
|
||||
|
|
14
main.c
14
main.c
|
@ -295,6 +295,20 @@ int main(int argc, char *argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (strcmp(cmd, "unboost") == 0) { /** **/
|
||||
xs *msg = msg_repulsion(&snac, url, "Announce");
|
||||
|
||||
if (msg != NULL) {
|
||||
enqueue_message(&snac, msg);
|
||||
|
||||
if (dbglevel) {
|
||||
xs_json_dump(msg, 4, stdout);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strcmp(cmd, "follow") == 0) { /** **/
|
||||
xs *msg = msg_follow(&snac, url);
|
||||
|
||||
|
|
1
snac.h
1
snac.h
|
@ -264,6 +264,7 @@ char *get_atto(const xs_dict *msg);
|
|||
xs_list *get_attachments(const xs_dict *msg);
|
||||
|
||||
xs_dict *msg_admiration(snac *snac, char *object, char *type);
|
||||
xs_dict *msg_repulsion(snac *user, char *id, char *type);
|
||||
xs_dict *msg_create(snac *snac, const xs_dict *object);
|
||||
xs_dict *msg_follow(snac *snac, const char *actor);
|
||||
|
||||
|
|
Loading…
Reference in a new issue