Better 'Delete' message logging.

This commit is contained in:
default 2022-10-20 10:34:32 +02:00
parent 394a4a4077
commit a16600e330
3 changed files with 12 additions and 5 deletions

View File

@ -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));

9
data.c
View File

@ -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;
}

2
snac.h
View File

@ -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);