|
|
@@ -5,6 +5,7 @@ import hashlib |
|
|
|
|
|
|
|
import html2text |
|
|
|
import requests |
|
|
|
from mastodon import Mastodon # type: ignore |
|
|
|
|
|
|
|
Comparison = Enum("Comparison", "GT GE LT LE EQ NE TRUE") |
|
|
|
|
|
|
@@ -48,7 +49,7 @@ DEFAULT_AVATAR_HASHES = [ |
|
|
|
"de7b5ead3476d53f3b943779699b7fa0" # Pleroma's avi.png |
|
|
|
] |
|
|
|
|
|
|
|
def check_criteria(user_dict: dict, criteria_settings: dict): |
|
|
|
def check_criteria(user_dict: dict, criteria_settings: dict) -> list: |
|
|
|
""" |
|
|
|
Check an account against criteria for auto-rejection. |
|
|
|
|
|
|
@@ -93,3 +94,25 @@ def check_criteria(user_dict: dict, criteria_settings: dict): |
|
|
|
rejected_criteria.append(key) |
|
|
|
|
|
|
|
return rejected_criteria |
|
|
|
|
|
|
|
def reject_follows(masto: Mastodon, criteria: dict): |
|
|
|
""" |
|
|
|
Performs automatic follow request rejection based on a set of criteria. |
|
|
|
|
|
|
|
Arguments: |
|
|
|
masto - an instance of mastodon.py's Mastodon class that is logged into an account in some way |
|
|
|
criteria - a dict containing the criteria to test on |
|
|
|
""" |
|
|
|
follow_requests = masto.follow_requests() |
|
|
|
|
|
|
|
rejections = [] |
|
|
|
|
|
|
|
for req in follow_requests: |
|
|
|
rejected_on = check_criteria(req, criteria) |
|
|
|
if rejected_on: |
|
|
|
masto.follow_request_reject(req['id']) |
|
|
|
req['rejected_on'] = rejected_on |
|
|
|
rejections.append(req) |
|
|
|
|
|
|
|
return rejections |
|
|
|
|