]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 1 Jul 2023 04:25:34 +0000 (06:25 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 1 Jul 2023 04:25:34 +0000 (06:25 +0200)
- update 'nsfw' to 'media_nsfw':
  UPDATE blocks SET block_level='media_nsfw' WHERE block_level='nsfw';
- don't allow block_level='nsfw'

fba/models/blocks.py
fba/networks/pleroma.py
fba/utils.py

index ec4fed2e03a20f1b6361cbae3520b91d4376eaab..a43908417ea4d063ea6100b3bc9f99fbee7107a3 100644 (file)
@@ -47,7 +47,7 @@ def update_reason(reason: str, blocker: str, blocked: str, block_level: str):
         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", "suspend", "silence"]:
+    elif block_level in ["accept", "suspend", "silence", "nsfw"]:
         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)
@@ -81,7 +81,7 @@ def update_last_seen(blocker: str, blocked: str, block_level: str):
         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", "suspend", "silence"]:
+    elif block_level in ["accept", "suspend", "silence", "nsfw"]:
         raise ValueError(f"blocked='{blocked}' has unwanted block_level='{block_level}'")
 
     database.cursor.execute(
@@ -113,7 +113,7 @@ def is_instance_blocked(blocker: str, blocked: str, block_level: str = None) ->
         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", "suspend", "silence"]:
+    elif block_level in ["accept", "suspend", "silence", "nsfw"]:
         raise ValueError(f"blocked='{blocked}' has unwanted block_level='{block_level}'")
 
     if block_level is None:
@@ -152,7 +152,7 @@ def add_instance(blocker: str, blocked: str, reason: str, block_level: str):
         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", "suspend", "silence"]:
+    elif block_level in ["accept", "suspend", "silence", "nsfw"]:
         raise ValueError(f"blocked='{blocked}' has unwanted block_level='{block_level}'")
 
     if reason is not None:
index 42ec809bcca4c8ffc2d51e4a947932104e13abdd..82d3e4ef39058a05385274a83674b54595e5f06b 100644 (file)
@@ -41,12 +41,12 @@ language_mapping = {
     "followers-only"   : "followers_only",
     "media removal"    : "media_removal",
     "media_removal"    : "media_removal",
-    "media force-set as sensitive": "nsfw",
-    "nsfw"             : "nsfw",
+    "media force-set as sensitive": "media_nsfw",
+    "nsfw"             : "media_nsfw",
     "reject"           : "reject",
     "suspended servers": "reject",
     "silenced servers" : "silenced",
-    "removal from \"the whole known network\" timeline": " federated_timeline_removal",
+    "removal from \"the whole known network\" timeline": "federated_timeline_removal",
 }
 
 def fetch_blocks(domain: str, nodeinfo_url: str) -> list:
@@ -349,8 +349,9 @@ def fetch_blocks_from_about(domain: str) -> dict:
         "filtered_media": [],
         "followers_only": [],
         "silenced"      : [],
-        "nsfw"          : [],
+        "media_nsfw"    : [],
         "media_removal" : [],
+        "federated_timeline_removal": [],
     }
 
     logger.debug("doc[]='%s'", type(doc))
index 5d794ffb0c3b5ec852c64295c1b09eb00f363e2c..177535311915ff63dcd1d2f612b36166ad32b806 100644 (file)
@@ -258,6 +258,9 @@ def alias_block_level(block_level: str) -> str:
     elif block_level == "suspend":
         logger.debug("Block level 'suspend' has been changed to 'suspended'")
         block_level = "suspended"
+    elif block_level == "nsfw":
+        logger.debug("Block level 'nsfw' has been changed to 'media_nsfw'")
+        block_level = "media_nsfw"
 
     logger.debug("block_level='%s' - EXIT!", block_level)
     return block_level