From: Mint <> Date: Thu, 20 Oct 2022 22:02:07 +0000 (+0300) Subject: New Masto API support X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=03358a3c6ef9fc3e16219c70d97e931e975a3426;p=fba.git New Masto API support --- diff --git a/fetch_blocks.py b/fetch_blocks.py index 15d1a6d..ccd89cb 100644 --- a/fetch_blocks.py +++ b/fetch_blocks.py @@ -58,7 +58,7 @@ def get_mastodon_blocks(domain: str) -> dict: return { "reject": blocks["Suspended servers"], "media_removal": blocks["Filtered media"], - "federated_timeline_removal": blocks["Limited servers"] + "followers_only": blocks["Limited servers"] + blocks["Silenced servers"], } @@ -273,7 +273,30 @@ for blocker, software in c.fetchall(): elif software == "mastodon": print(blocker) try: - json = get_mastodon_blocks(blocker) + # json endpoint for newer mastodongs + try: + json = { + "reject": [], + "media_removal": [], + "followers_only": [], + "report_removal": [] + } + blocks = get( + f"https://{blocker}/api/v1/instance/domain_blocks", headers=headers, timeout=5 + ).json() + for block in blocks: + entry = {'domain': block['domain'], 'hash': block['digest'], 'reason': block['comment']} + if block['severity'] == 'suspend': + json['reject'].append(entry) + elif block['severity'] == 'silence': + json['followers_only'].append(entry) + elif block['severity'] == 'reject_media': + json['media_removal'].append(entry) + elif block['severity'] == 'reject_reports': + json['report_removal'].append(entry) + except: + json = get_mastodon_blocks(blocker) + for block_level, blocks in json.items(): for instance in blocks: blocked, blocked_hash, reason = instance.values()