summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
authorGravatar default2024-02-22 13:52:45 +0100
committerGravatar default2024-02-22 13:52:45 +0100
commitf523e8c1783223f984d45b9da60efaac5bd4b524 (patch)
tree3ad4d792e49fb60de364e7606c0d77813a6d8faf /activitypub.c
parentAlso apply 1em patch to utils.c. (diff)
downloadsnac2-f523e8c1783223f984d45b9da60efaac5bd4b524.tar.gz
snac2-f523e8c1783223f984d45b9da60efaac5bd4b524.tar.xz
snac2-f523e8c1783223f984d45b9da60efaac5bd4b524.zip
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.
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c19
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)
1826 } 1826 }
1827 } 1827 }
1828 1828
1829 /* check the minimum acceptable account age */
1830 int min_account_age = xs_number_get(xs_dict_get(srv_config, "min_account_age"));
1831
1832 if (min_account_age > 0) {
1833 char *actor_date = xs_dict_get(actor_o, "published");
1834 if (!xs_is_null(actor_date)) {
1835 time_t actor_t = xs_parse_iso_date(actor_date, 0);
1836 int td = (int)(time(NULL) - actor_t);
1837
1838 snac_debug(snac, 2, xs_fmt("actor %s age: %d seconds", actor, td));
1839
1840 if (td < min_account_age) {
1841 srv_log(xs_fmt("rejected activity from %s (too new, %d seconds)", actor, td));
1842
1843 return 1;
1844 }
1845 }
1846 }
1847
1829 if (strcmp(type, "Follow") == 0) { /** **/ 1848 if (strcmp(type, "Follow") == 0) { /** **/
1830 if (!follower_check(snac, actor)) { 1849 if (!follower_check(snac, actor)) {
1831 /* ensure the actor object is here */ 1850 /* ensure the actor object is here */