diff options
author | default <nobody@localhost> | 2024-02-22 13:52:45 +0100 |
---|---|---|
committer | default <nobody@localhost> | 2024-02-22 13:52:45 +0100 |
commit | f523e8c1783223f984d45b9da60efaac5bd4b524 (patch) | |
tree | 3ad4d792e49fb60de364e7606c0d77813a6d8faf | |
parent | 1061414775f26324b2aeb76577ef1fffa1e223d3 (diff) |
Added a new `min_account_age` parameter to server.json.
By setting this value to a number of seconds, any activity from accounts
created newer than that, will be rejected.
-rw-r--r-- | activitypub.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/activitypub.c b/activitypub.c index d8f748e..33a260e 100644 --- a/activitypub.c +++ b/activitypub.c @@ -1826,6 +1826,25 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req) } } + /* check the minimum acceptable account age */ + int min_account_age = xs_number_get(xs_dict_get(srv_config, "min_account_age")); + + if (min_account_age > 0) { + char *actor_date = xs_dict_get(actor_o, "published"); + if (!xs_is_null(actor_date)) { + time_t actor_t = xs_parse_iso_date(actor_date, 0); + int td = (int)(time(NULL) - actor_t); + + snac_debug(snac, 2, xs_fmt("actor %s age: %d seconds", actor, td)); + + if (td < min_account_age) { + srv_log(xs_fmt("rejected activity from %s (too new, %d seconds)", actor, td)); + + return 1; + } + } + } + if (strcmp(type, "Follow") == 0) { /** **/ if (!follower_check(snac, actor)) { /* ensure the actor object is here */ |