parser.add_argument("--domain", help="Instance name (aka. domain)")
parser.add_argument("--software", help="Name of software, e.g. 'lemmy'")
parser.add_argument("--force", action="store_true", help="Include also already existing instances, otherwise only new are checked")
+ parser.add_argument("--delete-unwanted", action="store_true", help="Whether delete or keep (default) unwanted domains")
### Fetch blocks from registered instances or given ###
parser = subparser_command.add_parser(
logger.info("Checking %d domains ...", len(rows))
for row in rows:
logger.debug("Fetching peers from domain='%s',software='%s',nodeinfo_url='%s' ...", row["domain"], row["software"], row["nodeinfo_url"])
- if blacklist.is_blacklisted(row["domain"]):
- logger.debug("row[domain]='%s' is blacklisted - SKIPPED!", row["domain"])
+ if not domain_helper.is_wanted(row["domain"]):
+ logger.debug("row[domain]='%s' is not wanted - SKIPPED!", row["domain"])
+ if args.delete_unwanted:
+ logger.info("Deleting unwanted row[domain]='%s' ...", row["domain"])
+ instances.delete(row["domain"])
+ blocks.delete(row["domain"])
+ continue
+ elif blacklist.is_blacklisted(row["domain"]):
+ logger.warning("row[domain]='%s' is blacklisted - SKIPPED!", row["domain"])
continue
elif (args.force is None or not args.force) and args.domain is None and args.software is None and instances.is_recent(row["domain"], "last_blocked"):
logger.debug("row[domain]='%s' has recently been checked, args.force[]='%s' - SKIPPED!", row["domain"], type(args.force))
logger.debug("block_level='%s' - EXIT!", block_level)
return block_level
+
+def delete(domain: str):
+ logger.debug("domain='%s' - CALLED!", domain)
+ domain_helper.raise_on(domain)
+
+ database.cursor.execute(f"DELETE FROM blocks WHERE blocker = ?", [domain])
+ database.cursor.execute(f"DELETE FROM blocks WHERE blocked = ?", [domain])
+
+ logger.debug("Invoking commit() ...")
+ database.connection.commit()
+
+ logger.debug("EXIT!")
logger.debug("is_valid='%s' - EXIT!", is_valid)
return is_valid
+def delete(domain: str):
+ logger.debug("domain='%s' - CALLED!", domain)
+ domain_helper.raise_on(domain)
+
+ database.cursor.execute(f"DELETE FROM instances WHERE domain = ? LIMIT 1", [domain])
+
+ logger.debug("Invoking commit() ...")
+ database.connection.commit()
+
+ logger.debug("EXIT!")
+
def translate_idnas(rows: list, column: str):
logger.debug("rows[]='%s' - CALLED!", type(rows))