return peers
def fetch_blocks(domain: str) -> dict:
- print(f"DEBUG: domain='{domain}' - CALLED!")
+ # DEBUG: print(f"DEBUG: domain='{domain}' - CALLED!")
if type(domain) != str:
raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
elif domain == "":
raise ValueError(f"Parameter 'domain' is empty")
- print("DEBUG: Fetching misskey blocks from domain:", domain)
+ # DEBUG: print("DEBUG: Fetching misskey blocks from domain:", domain)
blocklist = {
"suspended": [],
"blocked" : []
# instances page-by-page, since that troonware doesn't support
# sending them all at once
try:
- print(f"DEBUG: Fetching offset='{offset}' from '{domain}' ...")
+ # DEBUG: print(f"DEBUG: Fetching offset='{offset}' from '{domain}' ...")
if offset == 0:
- print("DEBUG: Sending JSON API request to domain,step,offset:", domain, step, offset)
+ # DEBUG: print("DEBUG: Sending JSON API request to domain,step,offset:", domain, step, offset)
fetched = fba.post_json_api(domain, "/api/federation/instances", json.dumps({
"sort" : "+pubAt",
"host" : None,
"Origin": domain
})
else:
- print("DEBUG: Sending JSON API request to domain,step,offset:", domain, step, offset)
+ # DEBUG: print("DEBUG: Sending JSON API request to domain,step,offset:", domain, step, offset)
fetched = fba.post_json_api(domain, "/api/federation/instances", json.dumps({
"sort" : "+pubAt",
"host" : None,
"Origin": domain
})
- print("DEBUG: fetched():", len(fetched))
+ # DEBUG: print("DEBUG: fetched():", len(fetched))
if len(fetched) == 0:
- print("DEBUG: Returned zero bytes, exiting loop:", domain)
+ # DEBUG: print("DEBUG: Returned zero bytes, exiting loop:", domain)
break
elif len(fetched) != config.get("misskey_limit"):
- print(f"DEBUG: Fetched '{len(fetched)}' row(s) but expected: '{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:
- print("DEBUG: Raising offset by step:", step)
+ # DEBUG: print("DEBUG: Raising offset by step:", step)
offset = offset + step
count = 0
}
)
- print(f"DEBUG: count={count}")
+ # DEBUG: print(f"DEBUG: count={count}")
if count == 0:
- print(f"DEBUG: API is no more returning new instances, aborting loop!")
+ # DEBUG: print(f"DEBUG: API is no more returning new instances, aborting loop!")
break
except BaseException as e:
# same shit, different asshole ("blocked" aka full suspend)
try:
if offset == 0:
- print("DEBUG: Sending JSON API request to domain,step,offset:", domain, step, offset)
+ # DEBUG: print("DEBUG: Sending JSON API request to domain,step,offset:", domain, step, offset)
fetched = fba.post_json_api(domain, "/api/federation/instances", json.dumps({
"sort" : "+pubAt",
"host" : None,
"Origin": domain
})
else:
- print("DEBUG: Sending JSON API request to domain,step,offset:", domain, step, offset)
+ # DEBUG: print("DEBUG: Sending JSON API request to domain,step,offset:", domain, step, offset)
fetched = fba.post_json_api(domain, "/api/federation/instances", json.dumps({
"sort" : "+pubAt",
"host" : None,
"Origin": domain
})
- print("DEBUG: fetched():", len(fetched))
+ # DEBUG: print("DEBUG: fetched():", len(fetched))
if len(fetched) == 0:
- print("DEBUG: Returned zero bytes, exiting loop:", domain)
+ # DEBUG: print("DEBUG: Returned zero bytes, exiting loop:", domain)
break
elif len(fetched) != config.get("misskey_limit"):
- print(f"DEBUG: Fetched '{len(fetched)}' row(s) but expected: '{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:
- print("DEBUG: Raising offset by step:", step)
+ # DEBUG: print("DEBUG: Raising offset by step:", step)
offset = offset + step
count = 0
"reason": None
})
- print(f"DEBUG: count={count}")
+ # DEBUG: print(f"DEBUG: count={count}")
if count == 0:
- print(f"DEBUG: API is no more returning new instances, aborting loop!")
+ # DEBUG: print(f"DEBUG: API is no more returning new instances, aborting loop!")
break
except BaseException as e:
offset = 0
break
- print(f"DEBUG: Updating last_instance_fetch for domain='{domain}' ...")
+ # DEBUG: print(f"DEBUG: Updating last_instance_fetch for domain='{domain}' ...")
instances.update_last_instance_fetch(domain)
- print(f"DEBUG: Returning for domain='{domain}',blocked()={len(blocklist['blocked'])},suspended()={len(blocklist['suspended'])}")
+ # DEBUG: print(f"DEBUG: Returning for domain='{domain}',blocked()={len(blocklist['blocked'])},suspended()={len(blocklist['suspended'])}")
return {
"reject" : blocklist["blocked"],
"followers_only": blocklist["suspended"]