Log (and not notify) repeated likes and announces.

This commit is contained in:
default 2024-02-21 09:22:32 +01:00
parent ae6aafeb88
commit e9553379e9
3 changed files with 18 additions and 9 deletions

View file

@ -1955,10 +1955,13 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
if (xs_type(object) == XSTYPE_DICT) if (xs_type(object) == XSTYPE_DICT)
object = xs_dict_get(object, "id"); object = xs_dict_get(object, "id");
timeline_admire(snac, object, actor, 1); if (timeline_admire(snac, object, actor, 1) == 201) {
snac_log(snac, xs_fmt("new 'Like' %s %s", actor, object)); snac_log(snac, xs_fmt("new 'Like' %s %s", actor, object));
do_notify = 1; do_notify = 1;
} }
else
snac_log(snac, xs_fmt("repeated 'Like' from %s to %s", actor, object));
}
else else
if (strcmp(type, "Announce") == 0) { /** **/ if (strcmp(type, "Announce") == 0) { /** **/
if (xs_type(object) == XSTYPE_DICT) if (xs_type(object) == XSTYPE_DICT)
@ -1983,10 +1986,14 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
xs *who_o = NULL; xs *who_o = NULL;
if (valid_status(actor_request(snac, who, &who_o))) { if (valid_status(actor_request(snac, who, &who_o))) {
timeline_admire(snac, object, actor, 0); if (timeline_admire(snac, object, actor, 0) == 201) {
snac_log(snac, xs_fmt("new 'Announce' %s %s", actor, object)); snac_log(snac, xs_fmt("new 'Announce' %s %s", actor, object));
do_notify = 1; do_notify = 1;
} }
else
snac_log(snac, xs_fmt("repeated 'Announce' from %s to %s",
actor, object));
}
else else
snac_debug(snac, 1, xs_fmt("dropped 'Announce' on actor request error %s", who)); snac_debug(snac, 1, xs_fmt("dropped 'Announce' on actor request error %s", who));
} }

6
data.c
View file

@ -1107,7 +1107,7 @@ int timeline_add(snac *snac, const char *id, const xs_dict *o_msg)
} }
void timeline_admire(snac *snac, const char *id, const char *admirer, int like) int timeline_admire(snac *snac, const char *id, const char *admirer, int like)
/* updates a timeline entry with a new admiration */ /* updates a timeline entry with a new admiration */
{ {
/* if we are admiring this, add to both timelines */ /* if we are admiring this, add to both timelines */
@ -1116,10 +1116,12 @@ void timeline_admire(snac *snac, const char *id, const char *admirer, int like)
object_user_cache_add(snac, id, "private"); object_user_cache_add(snac, id, "private");
} }
object_admire(id, admirer, like); int ret = object_admire(id, admirer, like);
snac_debug(snac, 1, xs_fmt("timeline_admire (%s) %s %s", snac_debug(snac, 1, xs_fmt("timeline_admire (%s) %s %s",
like ? "Like" : "Announce", id, admirer)); like ? "Like" : "Announce", id, admirer));
return ret;
} }

2
snac.h
View file

@ -133,7 +133,7 @@ int timeline_del(snac *snac, char *id);
xs_list *timeline_simple_list(snac *snac, const char *idx_name, int skip, int show); xs_list *timeline_simple_list(snac *snac, const char *idx_name, int skip, int show);
xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show); xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show);
int timeline_add(snac *snac, const char *id, const xs_dict *o_msg); int timeline_add(snac *snac, const char *id, const xs_dict *o_msg);
void timeline_admire(snac *snac, const char *id, const char *admirer, int like); int timeline_admire(snac *snac, const char *id, const char *admirer, int like);
xs_list *timeline_top_level(snac *snac, xs_list *list); xs_list *timeline_top_level(snac *snac, xs_list *list);
xs_list *local_list(snac *snac, int max); xs_list *local_list(snac *snac, int max);