logger.debug("domain='%s' - CALLED!", domain)
domain_helper.raise_on(domain)
+ if not instances.is_registered(domain):
+ raise Exception(f"domain='{domain}' is not registered but function is invoked.")
+
logger.debug("Fetching mastodon blocks from domain='%s'", domain)
doc = None
for path in ["/about/more", "/about"]:
if header_text in blocklist or header_text.lower() in blocklist:
# replaced find_next_siblings with find_all_next to account for instances that e.g. hide lists in dropdown menu
for line in header.find_all_next("table")[0].find_all("tr")[1:]:
+ domain = line.find("span").text
+ hash = line.find("span")["title"][9:]
+ reason = line.find_all("td")[1].text
+
+ logger.debug("domain='%s',reason='%s' - BEFORE!", domain, reason)
+ domain = tidyup.domain(domain) if domain != "" else None
+ reason = tidyup.reason(reason) if reason != "" else None
+
+ logger.debug("domain='%s',reason='%s' - AFTER!", domain, reason)
+ if domain is None or domain == "":
+ logger.warning("domain='%s' is empty,line='%s' - SKIPPED!", domain, line)
+ continue
+
+ logger.debug("Appending domain='%s',hash='%s',reason='%s' to blocklist header_text='%s' ...", domain, hash, reason, blocklist)
blocklist[header_text].append({
- "domain": tidyup.domain(line.find("span").text),
- "hash" : tidyup.domain(line.find("span")["title"][9:]),
- "reason": tidyup.reason(line.find_all("td")[1].text),
+ "domain": domain,
+ "hash" : hash,
+ "reason": reason,
})
else:
logger.warning("header_text='%s' not found in blocklist()=%d", header_text, len(blocklist))
"followers_only": blocklist["Limited servers"] + blocklist["Silenced servers"],
}
-def fetch_blocks(domain: str, nodeinfo_url: str) -> list:
- logger.debug("domain='%s',nodeinfo_url='%s' - CALLED!", domain, nodeinfo_url)
+def fetch_blocks(domain: str) -> list:
+ logger.debug("domain='%s' - CALLED!", domain)
domain_helper.raise_on(domain)
- if not isinstance(nodeinfo_url, str):
- raise ValueError(f"Parameter nodeinfo_url[]='{type(nodeinfo_url)}' is not of type 'str'")
- elif nodeinfo_url == "":
- raise ValueError("Parameter 'nodeinfo_url' is empty")
+ if not instances.is_registered(domain):
+ raise Exception(f"domain='{domain}' is not registered but function is invoked.")
blocklist = list()
logger.debug("block[]='%s' is of type 'dict' - SKIPPED!", type(block))
continue
elif "domain" not in block:
+ logger.debug("block='%s'", block)
logger.warning("block()=%d does not contain element 'domain' - SKIPPED!", len(block))
continue
+ elif not domain_helper.is_wanted(block["domain"]):
+ logger.debug("block[domain]='%s' is not wanted - SKIPPED!", block["domain"])
+ continue
elif "severity" not in block:
logger.warning("block()=%d does not contain element 'severity' - SKIPPED!", len(block))
continue