summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2022-10-01 19:37:47 +0200
committerdefault <nobody@localhost>2022-10-01 19:37:47 +0200
commit82e9a03925d27d9228ac5a20445b02902a70d0ca (patch)
tree61fc680d00bfbfa02fdc77d7a85030187187323f
parent450c0e7aad09491b2abd177e695d3080c352af5e (diff)
Implemented 'Delete'.
-rw-r--r--activitypub.c29
-rw-r--r--html.c13
-rw-r--r--snac.h1
3 files changed, 40 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)
for (n = 0; lists[n]; n++) {
char *l = lists[n];
char *v;
+ xs *tl = NULL;
+ /* if it's a string, create a list with only one element */
if (xs_type(l) == XSTYPE_STRING) {
- if (xs_list_in(list, l) == -1)
- list = xs_list_append(list, l);
+ tl = xs_list_new();
+ tl = xs_list_append(tl, l);
+
+ l = tl;
}
- else
+
while (xs_list_iter(&l, &v)) {
if (expand_public && strcmp(v, public_address) == 0) {
/* iterate the followers and add them */
@@ -455,6 +459,25 @@ d_char *msg_undo(snac *snac, char *object)
}
+d_char *msg_delete(snac *snac, char *id)
+/* creates a 'Delete' + 'Tombstone' for a local entry */
+{
+ xs *tomb = xs_dict_new();
+ d_char *msg = NULL;
+
+ /* sculpt the tombstone */
+ tomb = xs_dict_append(tomb, "type", "Tombstone");
+ tomb = xs_dict_append(tomb, "id", id);
+
+ /* now create the Delete */
+ msg = msg_base(snac, "Delete", "@object", snac->actor, "@now", tomb);
+
+ msg = xs_dict_append(msg, "to", public_address);
+
+ return msg;
+}
+
+
d_char *msg_follow(snac *snac, char *actor)
/* creates a 'Follow' message */
{
diff --git a/html.c b/html.c
index d6df61d..1e2248c 100644
--- a/html.c
+++ b/html.c
@@ -930,6 +930,19 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size,
}
else
if (strcmp(action, L("Delete")) == 0) {
+ /* delete an entry */
+ if (xs_startswith(id, snac.actor)) {
+ /* it's a post by us: generate a delete */
+ xs *msg = msg_delete(&snac, id);
+
+ post(&snac, msg);
+
+ snac_log(&snac, xs_fmt("posted tombstone for %s", id));
+ }
+
+ timeline_del(&snac, id);
+
+ snac_log(&snac, xs_fmt("deleted entry %s", id));
}
else
status = 404;
diff --git a/snac.h b/snac.h
index afccc65..9a597b2 100644
--- a/snac.h
+++ b/snac.h
@@ -114,6 +114,7 @@ d_char *msg_create(snac *snac, char *object);
d_char *msg_follow(snac *snac, char *actor);
d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to);
d_char *msg_undo(snac *snac, char *object);
+d_char *msg_delete(snac *snac, char *id);
int activitypub_request(snac *snac, char *url, d_char **data);
int actor_request(snac *snac, char *actor, d_char **data);