diff options
| author | 2022-10-01 19:37:47 +0200 | |
|---|---|---|
| committer | 2022-10-01 19:37:47 +0200 | |
| commit | 82e9a03925d27d9228ac5a20445b02902a70d0ca (patch) | |
| tree | 61fc680d00bfbfa02fdc77d7a85030187187323f /activitypub.c | |
| parent | More snac-origin work. (diff) | |
| download | snac2-82e9a03925d27d9228ac5a20445b02902a70d0ca.tar.gz snac2-82e9a03925d27d9228ac5a20445b02902a70d0ca.tar.xz snac2-82e9a03925d27d9228ac5a20445b02902a70d0ca.zip | |
Implemented 'Delete'.
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/activitypub.c b/activitypub.c index 99fe498..21316c0 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -163,12 +163,16 @@ d_char *recipient_list(snac *snac, char *msg, int expand_public) | |||
| 163 | for (n = 0; lists[n]; n++) { | 163 | for (n = 0; lists[n]; n++) { |
| 164 | char *l = lists[n]; | 164 | char *l = lists[n]; |
| 165 | char *v; | 165 | char *v; |
| 166 | xs *tl = NULL; | ||
| 166 | 167 | ||
| 168 | /* if it's a string, create a list with only one element */ | ||
| 167 | if (xs_type(l) == XSTYPE_STRING) { | 169 | if (xs_type(l) == XSTYPE_STRING) { |
| 168 | if (xs_list_in(list, l) == -1) | 170 | tl = xs_list_new(); |
| 169 | list = xs_list_append(list, l); | 171 | tl = xs_list_append(tl, l); |
| 172 | |||
| 173 | l = tl; | ||
| 170 | } | 174 | } |
| 171 | else | 175 | |
| 172 | while (xs_list_iter(&l, &v)) { | 176 | while (xs_list_iter(&l, &v)) { |
| 173 | if (expand_public && strcmp(v, public_address) == 0) { | 177 | if (expand_public && strcmp(v, public_address) == 0) { |
| 174 | /* iterate the followers and add them */ | 178 | /* iterate the followers and add them */ |
| @@ -455,6 +459,25 @@ d_char *msg_undo(snac *snac, char *object) | |||
| 455 | } | 459 | } |
| 456 | 460 | ||
| 457 | 461 | ||
| 462 | d_char *msg_delete(snac *snac, char *id) | ||
| 463 | /* creates a 'Delete' + 'Tombstone' for a local entry */ | ||
| 464 | { | ||
| 465 | xs *tomb = xs_dict_new(); | ||
| 466 | d_char *msg = NULL; | ||
| 467 | |||
| 468 | /* sculpt the tombstone */ | ||
| 469 | tomb = xs_dict_append(tomb, "type", "Tombstone"); | ||
| 470 | tomb = xs_dict_append(tomb, "id", id); | ||
| 471 | |||
| 472 | /* now create the Delete */ | ||
| 473 | msg = msg_base(snac, "Delete", "@object", snac->actor, "@now", tomb); | ||
| 474 | |||
| 475 | msg = xs_dict_append(msg, "to", public_address); | ||
| 476 | |||
| 477 | return msg; | ||
| 478 | } | ||
| 479 | |||
| 480 | |||
| 458 | d_char *msg_follow(snac *snac, char *actor) | 481 | d_char *msg_follow(snac *snac, char *actor) |
| 459 | /* creates a 'Follow' message */ | 482 | /* creates a 'Follow' message */ |
| 460 | { | 483 | { |