]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 24 Jun 2023 11:31:56 +0000 (13:31 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 24 Jun 2023 11:31:56 +0000 (13:31 +0200)
- fixed rss.xml view
- also maybe search for hash (only mastodon provide it)

fba/commands.py
fba/networks/pleroma.py
templates/rss.xml

index 5ba69abc1afdd0ae671cde9c91a6c4bdb660e022..2374f06ca17d9713d073ab70f6c538a50a31b9c9 100644 (file)
@@ -267,61 +267,61 @@ def fetch_blocks(args: argparse.Namespace) -> int:
 
         logger.info("Checking %d entries from blocker='%s',software='%s' ...", len(blocking), blocker, software)
         for block in blocking:
-            logger.debug("blocked='%s',block_level='%s',reason='%s'", block['blocked'], block['block_level'], block['reason'])
+            logger.debug("blocked='%s',block_level='%s',reason='%s'", block["blocked"], block['block_level'], block["reason"])
 
             if block['block_level'] == "":
-                logger.warning("block_level is empty, blocker='%s',blocked='%s'", block['blocker'], block['blocked'])
+                logger.warning("block_level is empty, blocker='%s',blocked='%s'", block["blocker"], block["blocked"])
                 continue
 
-            logger.debug("blocked='%s',reason='%s' - BEFORE!", block['blocked'], block['reason'])
-            block['blocked'] = tidyup.domain(block['blocked'])
-            block['reason']  = tidyup.reason(block['reason']) if block['reason'] is not None and block['reason'] != "" else None
-            logger.debug("blocked='%s',reason='%s' - AFTER!", block['blocked'], block['reason'])
+            logger.debug("blocked='%s',reason='%s' - BEFORE!", block["blocked"], block["reason"])
+            block["blocked"] = tidyup.domain(block["blocked"])
+            block["reason"]  = tidyup.reason(block["reason"]) if block["reason"] is not None and block["reason"] != "" else None
+            logger.debug("blocked='%s',reason='%s' - AFTER!", block["blocked"], block["reason"])
 
-            if block['blocked'] == "":
+            if block["blocked"] == "":
                 logger.warning("blocked is empty, blocker='%s'", blocker)
                 continue
-            elif block['blocked'].count("*") > 0:
+            elif block["blocked"].count("*") > 0:
                 logger.debug("blocker='%s' uses obfuscated domains, marking ...", blocker)
                 instances.set_has_obfuscation(blocker, True)
 
                 # Some friendica servers also obscure domains without hash
-                row = instances.deobfuscate("*", block['blocked'])
+                row = instances.deobfuscate("*", block["blocked"], block["hash"] if "hash" in block else None)
 
                 logger.debug("row[]='%s'", type(row))
                 if row is None:
-                    logger.warning("Cannot deobfuscate blocked='%s',blocker='%s',software='%s' - SKIPPED!", block['blocked'], blocker, software)
+                    logger.warning("Cannot deobfuscate blocked='%s',blocker='%s',software='%s' - SKIPPED!", block["blocked"], blocker, software)
                     continue
 
-                block['blocked'] = row[0]
+                block["blocked"] = row[0]
                 origin           = row[1]
                 nodeinfo_url     = row[2]
-            elif block['blocked'].count("?") > 0:
+            elif block["blocked"].count("?") > 0:
                 logger.debug("blocker='%s' uses obfuscated domains, marking ...", blocker)
                 instances.set_has_obfuscation(blocker, True)
 
                 # Some obscure them with question marks, not sure if that's dependent on version or not
-                row = instances.deobfuscate("?", block['blocked'])
+                row = instances.deobfuscate("?", block["blocked"] if "hash" in block else None)
 
                 logger.debug("row[]='%s'", type(row))
                 if row is None:
-                    logger.warning("Cannot deobfuscate blocked='%s',blocker='%s',software='%s' - SKIPPED!", block['blocked'], blocker, software)
+                    logger.warning("Cannot deobfuscate blocked='%s',blocker='%s',software='%s' - SKIPPED!", block["blocked"], blocker, software)
                     continue
 
-                block['blocked'] = row[0]
+                block["blocked"] = row[0]
                 origin           = row[1]
                 nodeinfo_url     = row[2]
 
-            logger.debug("Looking up instance by domainm, blocked='%s'", block['blocked'])
-            if not utils.is_domain_wanted(block['blocked']):
-                logger.debug("blocked='%s' is not wanted - SKIPPED!", block['blocked'])
+            logger.debug("Looking up instance by domainm, blocked='%s'", block["blocked"])
+            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'])
+                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)
-                federation.fetch_instances(block['blocked'], blocker, None, inspect.currentframe().f_code.co_name)
+            elif not instances.is_registered(block["blocked"]):
+                logger.debug("Hash wasn't found, adding: blocked='%s',blocker='%s'", block["blocked"], blocker)
+                federation.fetch_instances(block["blocked"], blocker, None, inspect.currentframe().f_code.co_name)
 
             if block['block_level'] == "silence":
                 logger.debug("Block level 'silence' has been changed to 'silenced'")
@@ -330,24 +330,24 @@ def fetch_blocks(args: argparse.Namespace) -> int:
                 logger.debug("Block level 'suspend' has been changed to 'suspended'")
                 block['block_level'] = "suspended"
 
-            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 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'])
 
                 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'])
+                    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'],
+                        "blocked": block["blocked"],
+                        "reason" : block["reason"],
                     })
             else:
-                logger.debug("Updating block last seen and reason for blocker='%s',blocked='%s' ...", blocker, block['blocked'])
-                blocks.update_last_seen(blocker, block['blocked'], block['block_level'])
-                blocks.update_reason(block['reason'], blocker, block['blocked'], block['block_level'])
+                logger.debug("Updating block last seen and reason for blocker='%s',blocked='%s' ...", blocker, block["blocked"])
+                blocks.update_last_seen(blocker, block["blocked"], block['block_level'])
+                blocks.update_reason(block["reason"], blocker, block["blocked"], block['block_level'])
 
-            logger.debug("Invoking cookies.clear(%s) ...", block['blocked'])
-            cookies.clear(block['blocked'])
+            logger.debug("Invoking cookies.clear(%s) ...", block["blocked"])
+            cookies.clear(block["blocked"])
 
         if instances.has_pending(blocker):
             logger.debug("Invoking instances.update_data(%s) ...", blocker)
@@ -777,14 +777,14 @@ def fetch_oliphant(args: argparse.Namespace) -> int:
     for block in blocklists:
         # Is domain given and not equal blocker?
         if isinstance(args.domain, str) and args.domain != block["blocker"]:
-            logger.debug("Skipping blocker='%s', not matching args.domain='%s'", block['blocker'], args.domain)
+            logger.debug("Skipping blocker='%s', not matching args.domain='%s'", block["blocker"], args.domain)
             continue
         elif args.domain in domains:
             logger.debug("args.domain='%s' already handled - SKIPPED!", args.domain)
             continue
 
         # Fetch this URL
-        logger.info("Fetching csv_url='%s' for blocker='%s' ...", block['csv_url'], block['blocker'])
+        logger.info("Fetching csv_url='%s' for blocker='%s' ...", block['csv_url'], block["blocker"])
         response = utils.fetch_url(f"{base_url}/{block['csv_url']}", network.web_headers, (config.get("connection_timeout"), config.get("read_timeout")))
 
         logger.debug("response.ok='%s',response.status_code=%d,response.text()=%d", response.ok, response.status_code, len(response.text))
@@ -832,8 +832,8 @@ def fetch_txt(args: argparse.Namespace) -> int:
 
     logger.info("Checking %d text file(s) ...", len(urls))
     for row in urls:
-        logger.debug("Fetching row[url]='%s' ...", row['url'])
-        response = utils.fetch_url(row['url'], network.web_headers, (config.get("connection_timeout"), config.get("read_timeout")))
+        logger.debug("Fetching row[url]='%s' ...", row["url"])
+        response = utils.fetch_url(row["url"], network.web_headers, (config.get("connection_timeout"), config.get("read_timeout")))
 
         logger.debug("response.ok='%s',response.status_code=%d,response.text()=%d", response.ok, response.status_code, len(response.text))
         if response.ok and response.status_code < 300 and response.text != "":
@@ -850,8 +850,8 @@ def fetch_txt(args: argparse.Namespace) -> int:
                     logger.debug("domain='%s' is not wanted - SKIPPED!", domain)
                     continue
 
-                logger.debug("domain='%s',row[blocker]='%s'", domain, row['blocker'])
-                processed = utils.process_domain(domain, row['blocker'], inspect.currentframe().f_code.co_name)
+                logger.debug("domain='%s',row[blocker]='%s'", domain, row["blocker"])
+                processed = utils.process_domain(domain, row["blocker"], inspect.currentframe().f_code.co_name)
 
                 logger.debug("processed='%s'", processed)
                 if not processed:
index f8fb931f9c8f69c628eac9a661bc1ccc364818e1..9998321198b5728457ee40ca59c137240b3abed8 100644 (file)
@@ -225,10 +225,10 @@ def fetch_blocks(domain: str, nodeinfo_url: str) -> list:
 
                 logger.debug("Checking %d blockdict records ...", len(blockdict))
                 for block in blockdict:
-                    logger.debug("block[blocked]='%s',blocked='%s'", block['blocked'], blocked)
-                    if block['blocked'] == blocked:
-                        logger.debug("Updating reason='%s' for blocker='%s'", reason, block['blocked'])
-                        block['reason'] = reason
+                    logger.debug("block[blocked]='%s',blocked='%s'", block["blocked"], blocked)
+                    if block["blocked"] == blocked:
+                        logger.debug("Updating reason='%s' for blocker='%s'", reason, block["blocked"])
+                        block["reason"] = reason
 
     elif "quarantined_instances_info" in data and "quarantined_instances" in data["quarantined_instances_info"]:
         logger.debug("Found 'quarantined_instances_info' in JSON response: domain='%s'", domain)
@@ -263,10 +263,10 @@ def fetch_blocks(domain: str, nodeinfo_url: str) -> list:
 
             logger.debug("Checking %d blockdict records ...", len(blockdict))
             for block in blockdict:
-                logger.debug("block[blocked]='%s',blocked='%s'", block['blocked'], blocked)
-                if block['blocked'] == blocked:
-                    logger.debug("Updating reason='%s' for blocker='%s'", reason, block['blocked'])
-                    block['reason'] = reason
+                logger.debug("block[blocked]='%s',blocked='%s'", block["blocked"], blocked)
+                if block["blocked"] == blocked:
+                    logger.debug("Updating reason='%s' for blocker='%s'", reason, block["blocked"])
+                    block["reason"] = reason
     else:
         logger.warning("Cannot find 'mrf_simple_info' or 'quarantined_instances_info' in JSON reply: domain='%s'", domain)
 
index 5d2c06db2deff7ffdf6fec6ef51fe0e852e74b6a..477e5627f91f5416c11b68121ca92ade9cfa4b2f 100644 (file)
@@ -9,7 +9,7 @@
  <item>
   <title>{{block['blocker']}} has applied '{{block['block_level']}}' restriction to {{block['blocked']}}</title>
   <description>{{block['reason']}}</description>
-  <link>https://{{hostname}}/top?mode=reverse&amp;domain={{block['blocker']}}</link>
+  <link>https://{{hostname}}/top?mode=reverse&amp;value={{block['blocker']}}</link>
   <pubDate>{{block['first_seen']}}</pubDate>
  </item>
  {% endfor %}