From a16600e3307050619d4866f95ebd0fb43034005c Mon Sep 17 00:00:00 2001 From: default Date: Thu, 20 Oct 2022 10:34:32 +0200 Subject: [PATCH] Better 'Delete' message logging. --- activitypub.c | 6 ++++-- data.c | 9 +++++++-- snac.h | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/activitypub.c b/activitypub.c index 7ac4c5f..992dbff 100644 --- a/activitypub.c +++ b/activitypub.c @@ -781,8 +781,10 @@ int process_message(snac *snac, char *msg, char *req) if (xs_type(object) == XSTYPE_DICT) object = xs_dict_get(object, "id"); - timeline_del(snac, object); - snac_log(snac, xs_fmt("received delete request for %s", object)); + if (valid_status(timeline_del(snac, object))) + snac_log(snac, xs_fmt("New 'Delete' %s %s", actor, object)); + else + snac_debug(snac, 1, xs_fmt("ignored 'Delete' for unknown object %s", object)); } else snac_debug(snac, 1, xs_fmt("process_message type '%s' ignored", type)); diff --git a/data.c b/data.c index e86f97f..cef4028 100644 --- a/data.c +++ b/data.c @@ -321,10 +321,11 @@ d_char *timeline_find(snac *snac, char *id) } -void timeline_del(snac *snac, char *id) +int timeline_del(snac *snac, char *id) /* deletes a message from the timeline */ { - xs *fn = _timeline_find_fn(snac, id); + int ret = 404; + xs *fn = _timeline_find_fn(snac, id); if (fn != NULL) { xs *lfn = NULL; @@ -337,7 +338,11 @@ void timeline_del(snac *snac, char *id) if (unlink(lfn) != -1) snac_debug(snac, 1, xs_fmt("timeline_del (local) %s", id)); + + ret = 200; } + + return ret; } diff --git a/snac.h b/snac.h index b3e50b7..823c60c 100644 --- a/snac.h +++ b/snac.h @@ -60,7 +60,7 @@ double timeline_mtime(snac *snac); int timeline_here(snac *snac, char *id); d_char *_timeline_find_fn(snac *snac, char *id); d_char *timeline_find(snac *snac, char *id); -void timeline_del(snac *snac, char *id); +int timeline_del(snac *snac, char *id); d_char *timeline_get(snac *snac, char *fn); d_char *timeline_list(snac *snac, int max); int timeline_add(snac *snac, char *id, char *o_msg, char *parent, char *referrer);