commit f523e8c
default
·
2024-02-22 12:52:45 +0000 UTC
parent 1061414
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.
1 files changed,
+19,
-0
+19,
-0
1@@ -1826,6 +1826,25 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
2 }
3 }
4
5+ /* check the minimum acceptable account age */
6+ int min_account_age = xs_number_get(xs_dict_get(srv_config, "min_account_age"));
7+
8+ if (min_account_age > 0) {
9+ char *actor_date = xs_dict_get(actor_o, "published");
10+ if (!xs_is_null(actor_date)) {
11+ time_t actor_t = xs_parse_iso_date(actor_date, 0);
12+ int td = (int)(time(NULL) - actor_t);
13+
14+ snac_debug(snac, 2, xs_fmt("actor %s age: %d seconds", actor, td));
15+
16+ if (td < min_account_age) {
17+ srv_log(xs_fmt("rejected activity from %s (too new, %d seconds)", actor, td));
18+
19+ return 1;
20+ }
21+ }
22+ }
23+
24 if (strcmp(type, "Follow") == 0) { /** **/
25 if (!follower_check(snac, actor)) {
26 /* ensure the actor object is here */