logger.info("Checking %d entries ...", len(rows))
for blocker, software, origin, nodeinfo_url in rows:
logger.debug("blocker='%s',software='%s',origin='%s',nodeinfo_url='%s'", blocker, software, origin, nodeinfo_url)
- blockdict = list()
blocker = tidyup.domain(blocker)
logger.debug("blocker='%s' - AFTER!", blocker)
instances.set_has_obfuscation(blocker, False)
blocking = list()
+ blockdict = list()
if software == "pleroma":
logger.info("blocker='%s',software='%s'", blocker, software)
blocking = pleroma.fetch_blocks(blocker, nodeinfo_url)
if not utils.is_domain_wanted(block['blocked']):
logger.debug("blocked='%s' is not wanted - SKIPPED!", block['blocked'])
continue
+ elif block['block_level'] in ["accept", "accepted"]:
+ logger.debug("blocked='%s' is accepted, not wanted here - SKIPPED!", block['blocked'])
+ continue
elif not instances.is_registered(block['blocked']):
logger.debug("Hash wasn't found, adding: blocked='%s',blocker='%s'", block['blocked'], blocker)
try:
logger.warning("Exception during adding blocked='%s',blocker='%s': '%s'", block['blocked'], blocker, type(exception))
continue
+ if block['block_level'] == "silence":
+ logger.debug("Block level 'silence' has been changed to 'silenced'")
+ block['block_level'] = "silenced"
+
if not blocks.is_instance_blocked(blocker, block['blocked'], block['block_level']):
+ logger.debug("Invoking blocks.add_instance(%s, %s, %s, %s)", blocker, block['blocked'], block['reason'], block['block_level'])
blocks.add_instance(blocker, block['blocked'], block['reason'], block['block_level'])
- if block['block_level'] == "reject":
+ logger.debug("block_level='%s',config[bot_enabled]=%s", block['block_level'], config.get("bot_enabled"))
+ if block['block_level'] == "reject" and config.get("bot_enabled"):
+ logger.debug("blocker='%s' has blocked '%s' with reason='%s' - Adding to bot notification ...", blocker, block['blocked'], block['reason'])
blockdict.append({
"blocked": block['blocked'],
"reason" : block['reason'],
logger.debug("Invoking commit() ...")
database.connection.commit()
- if config.get("bot_enabled") and len(blockdict) > 0:
- network.send_bot_post(blocker, blockdict)
-
logger.debug("Invoking cookies.clear(%s) ...", blocker)
cookies.clear(blocker)
+ logger.debug("config[bot_enabled]='%s',blockdict()=%d'", config.get("bot_enabled"), len(blockdict))
+ if config.get("bot_enabled") and len(blockdict) > 0:
+ logger.info("Sending bot POST for blocker='%s,blockdict()=%d ...", blocker, len(blockdict))
+ network.send_bot_post(blocker, blockdict)
+
logger.debug("Success! - EXIT!")
return 0
raise ValueError(f"Parameter block_level[]='{type(block_level)}' is not 'str'")
elif block_level == "":
raise ValueError("Parameter 'block_level' is empty")
- elif block_level in ["accept", "suspended", "silenced"]:
+ elif block_level in ["accept", "suspended", "silence"]:
raise ValueError(f"block_level='{block_level}' is not wanted.")
logger.debug("Updating block reason='%s',blocker='%s',blocked='%s',block_level='%s'", reason, blocker, blocked, block_level)
raise ValueError(f"Parameter block_level[]='{type(block_level)}' is not 'str'")
elif block_level == "":
raise ValueError("Parameter 'block_level' is empty")
- elif block_level in ["accept", "suspended", "silenced"]:
- raise ValueError("Accepted domains are not wanted here")
+ elif block_level in ["accept", "suspended", "silence"]:
+ raise ValueError(f"blocked='{blocked}' has unwanted block_level='{block_level}'")
database.cursor.execute(
"UPDATE blocks SET last_seen = ? WHERE blocker = ? AND blocked = ? AND block_level = ? LIMIT 1",
raise ValueError(f"Parameter block_level[]='{type(block_level)}' is not of type 'str'")
elif block_level == "":
raise ValueError("Parameter 'block_level' is empty")
- elif block_level in ["accept", "suspended", "silenced"]:
- raise ValueError("Accepted domains are not wanted here")
+ elif block_level in ["accept", "suspended", "silence"]:
+ raise ValueError(f"blocked='{blocked}' has unwanted block_level='{block_level}'")
database.cursor.execute(
"SELECT * FROM blocks WHERE blocker = ? AND blocked = ? AND block_level = ? LIMIT 1",
raise Exception(f"blocker='{blocker}' is blacklisted but function invoked")
elif blacklist.is_blacklisted(blocked):
raise Exception(f"blocked='{blocked}' is blacklisted but function invoked")
- elif block_level in ["accept", "suspended", "silenced"]:
- raise ValueError("Accepted domains are not wanted here")
+ elif block_level in ["accept", "suspended", "silence"]:
+ raise ValueError(f"blocked='{blocked}' has unwanted block_level='{block_level}'")
if reason is not None:
# Maybe needs cleaning
elif block_level == "suspended":
logger.debug("domain='%s', mapping 'suspended' to 'suspend'", domain)
block_level = "suspend"
- elif block_level == "silenced":
- logger.debug("domain='%s', mapping 'silenced' to 'silence'", domain)
- block_level = "silence"
+ elif block_level == "silence":
+ logger.debug("domain='%s', mapping 'silence' to 'silenced'", domain)
+ block_level = "silenced"
logger.debug("Checking %d entries from domain='%s',block_level='%s' ...", len(blocklist), domain, block_level)
if len(blocklist) > 0:
elif block_level == "suspended":
logger.debug("domain='%s', mapping 'suspended' to 'suspend'", domain)
block_level = "suspend"
- elif block_level == "silenced":
- logger.debug("domain='%s', mapping 'silenced' to 'silence'", domain)
- block_level = "silence"
+ elif block_level == "silence":
+ logger.debug("domain='%s', mapping 'silence' to 'silenced'", domain)
+ block_level = "silenced"
logger.debug("Checking %d entries from domain='%s',block_level='%s' ...", len(info.items()), domain, block_level)
for blocked, reason in info.items():