result = {}
for blocker, blocked, block_level, reason, first_seen, last_seen in blocklist:
+ if reason != None and reason != "":
+ reason = reason.replace(",", " ").replace(" ", " ")
+
entry = {
"blocker" : blocker,
"blocked" : blocked,
"first_seen": first_seen,
"last_seen" : last_seen
}
+
if block_level in result:
result[block_level].append(entry)
else:
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import bs4
+import inspect
import validators
from fba import blacklist
"reject" : [],
"media_removal" : [],
"followers_only": [],
- "report_removal": []
+ "report_removal": [],
}
# handling CSRF, I've saw at least one server requiring it to access the endpoint
# DEBUG: print(f"DEBUG: Checking {len(blocklist)} entries from domain='{domain}',software='mastodon',block_level='{block_level}' ...")
for block in blocklist:
+ # DEBUG: print(f"DEBUG: block[]='{type(block)}'")
blocked, blocked_hash, reason = block.values()
- # DEBUG: print("DEBUG: blocked,hash,reason:", blocked, blocked_hash, reason)
+ # DEBUG: print(f"DEBUG: blocked='{blocked}',blocked_hash='{blocked_hash}',reason='{reason}':")
blocked = fba.tidyup_domain(blocked)
- # DEBUG: print("DEBUG: AFTER-blocked:", blocked)
+ reason = fba.tidyup_reason(reason)
+ # DEBUG: print(f"DEBUG: blocked='{blocked}',reason='{reason}' - AFTER!")
if blocked == "":
print("WARNING: blocked is empty:", domain)
# DEBUG: print(f"DEBUG: fetched()={len(fetched)}")
if len(fetched) == 0:
- # DEBUG: print("DEBUG: Returned zero bytes, exiting loop:", domain)
+ # DEBUG: print(f"DEBUG: Returned zero bytes, exiting loop, domain='{domain}'")
break
elif len(fetched) != config.get("misskey_limit"):
# DEBUG: print(f"DEBUG: Fetched '{len(fetched)}' row(s) but expected: '{config.get('misskey_limit')}'")
offset = offset + (config.get("misskey_limit") - len(fetched))
else:
- # DEBUG: print("DEBUG: Raising offset by step:", step)
+ # DEBUG: print(f"DEBUG: Raising offset by step={step}")
offset = offset + step
# Check records
already = 0
for row in fetched:
- # DEBUG: print(f"DEBUG: row():{len(row)}")
+ # DEBUG: print(f"DEBUG: row()={len(row)}")
if not "host" in row:
print(f"WARNING: row()={len(row)} does not contain key 'host': {row},domain='{domain}'")
continue
# DEBUG: print(f"DEBUG: Updating last_instance_fetch for domain='{domain}' ...")
instances.update_last_instance_fetch(domain)
- # DEBUG: print("DEBUG: Returning peers[]:", type(peers))
+ # DEBUG: print(f"DEBUG: Returning peers[]='{type(peers)}'")
return peers