mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
Implemented 'Delete'.
This commit is contained in:
parent
450c0e7aad
commit
82e9a03925
3 changed files with 40 additions and 3 deletions
|
@ -163,12 +163,16 @@ d_char *recipient_list(snac *snac, char *msg, int expand_public)
|
||||||
for (n = 0; lists[n]; n++) {
|
for (n = 0; lists[n]; n++) {
|
||||||
char *l = lists[n];
|
char *l = lists[n];
|
||||||
char *v;
|
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_type(l) == XSTYPE_STRING) {
|
||||||
if (xs_list_in(list, l) == -1)
|
tl = xs_list_new();
|
||||||
list = xs_list_append(list, l);
|
tl = xs_list_append(tl, l);
|
||||||
|
|
||||||
|
l = tl;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
while (xs_list_iter(&l, &v)) {
|
while (xs_list_iter(&l, &v)) {
|
||||||
if (expand_public && strcmp(v, public_address) == 0) {
|
if (expand_public && strcmp(v, public_address) == 0) {
|
||||||
/* iterate the followers and add them */
|
/* 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)
|
d_char *msg_follow(snac *snac, char *actor)
|
||||||
/* creates a 'Follow' message */
|
/* creates a 'Follow' message */
|
||||||
{
|
{
|
||||||
|
|
13
html.c
13
html.c
|
@ -930,6 +930,19 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (strcmp(action, L("Delete")) == 0) {
|
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
|
else
|
||||||
status = 404;
|
status = 404;
|
||||||
|
|
1
snac.h
1
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_follow(snac *snac, char *actor);
|
||||||
d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to);
|
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_undo(snac *snac, char *object);
|
||||||
|
d_char *msg_delete(snac *snac, char *id);
|
||||||
|
|
||||||
int activitypub_request(snac *snac, char *url, d_char **data);
|
int activitypub_request(snac *snac, char *url, d_char **data);
|
||||||
int actor_request(snac *snac, char *actor, d_char **data);
|
int actor_request(snac *snac, char *actor, d_char **data);
|
||||||
|
|
Loading…
Reference in a new issue