try:
# DEBUG: print("DEBUG: Executing SQL:", sql_string)
cursor.execute(sql_string, fields)
- # DEBUG: print(f"DEBUG: Success! (rowcount={cursor.rowcount })")
+ # DEBUG: print(f"DEBUG: Success! (rowcount={cursor.rowcount })")
if cursor.rowcount == 0:
print(f"WARNING: Did not update any rows: domain='{domain}',fields()={len(fields)} - EXIT!")
return
# DEBUG: print("DEBUG: Updating block reason:", reason, blocker, blocked, block_level)
try:
cursor.execute(
- "UPDATE blocks SET reason = ?, last_seen = ? WHERE blocker = ? AND blocked = ? AND block_level = ? AND reason = ''",
+ "UPDATE blocks SET reason = ?, last_seen = ? WHERE blocker = ? AND blocked = ? AND block_level = ? AND reason IN ('','unknown') LIMIT 1",
(
reason,
time.time(),
# DEBUG: print(f"DEBUG: cursor.rowcount={cursor.rowcount}")
if cursor.rowcount == 0:
- print("WARNING: Did not update any rows:", blocker, blocked)
+ # DEBUG: print(f"DEBUG: Did not update any rows: blocker='{blocker}',blocked='{blocked}',block_level='{block_level}',reason='{reason}' - EXIT!")
return
except BaseException as e:
# DEBUG: print("DEBUG: Updating last_seen for:", blocker, blocked, block_level)
try:
cursor.execute(
- "UPDATE blocks SET last_seen = ? WHERE blocker = ? AND blocked = ? AND block_level = ?",
+ "UPDATE blocks SET last_seen = ? WHERE blocker = ? AND blocked = ? AND block_level = ? LIMIT 1",
(
time.time(),
blocker,
)
)
+ # DEBUG: print(f"DEBUG: cursor.rowcount={cursor.rowcount}")
if cursor.rowcount == 0:
- print("WARNING: Did not update any rows:", domain)
+ # DEBUG: print(f"DEBUG: Did not update any rows: blocker='{blocker}',blocked='{blocked}',block_level='{block_level}' - EXIT!")
return
except BaseException as e:
- print(f"ERROR: failed SQL query: last_seen='{last_seen}',blocker='{blocker}',blocked='{blocked}',block_level='{block_level}',exception[{type(e)}]:'{str(e)}'")
+ print(f"ERROR: failed SQL query: blocker='{blocker}',blocked='{blocked}',block_level='{block_level}',exception[{type(e)}]:'{str(e)}'")
sys.exit(255)
# DEBUG: print("DEBUG: EXIT!")
elif is_blacklisted(blocked):
raise Exception(f"blocked='{blocked}' is blacklisted but function invoked")
- print("INFO: New block:", blocker, blocked, reason, block_level)
+ print(f"INFO: New block: blocker='{blocker}',blocked='{blocked}', reason='{reason}', block_level='{block_level}'")
try:
cursor.execute(
"INSERT INTO blocks (blocker, blocked, reason, block_level, first_seen, last_seen) VALUES(?, ?, ?, ?, ?, ?)",
print("WARNING: block_level is now empty!")
continue
+ # DEBUG: print(f"DEBUG: Checking {len(blocks)} entries from blocker='{blocker}',software='{software}',block_level='{block_level}' ...")
for blocked in blocks:
# DEBUG: print("DEBUG: BEFORE blocked:", blocked)
blocked = fba.tidyup(blocked)
"reason" : None
})
else:
- # DEBUG: print("DEBUG: Updating last_seen:", blocker, blocked, block_level)
+ print(f"DEBUG: Updating block last seen for blocker='{blocker}',blocked='{blocked}' ...")
fba.update_last_seen(blocker, blocked, block_level)
fba.connection.commit()
print("WARNING: block_level is now empty!")
continue
+ # DEBUG: print(f"DEBUG: Checking {len(info.items())} entries from blocker='{blocker}',software='{software}',block_level='{block_level}' ...")
for blocked, reason in info.items():
# DEBUG: print("DEBUG: BEFORE blocked:", blocked)
blocked = fba.tidyup(blocked)
# DEBUG: print("DEBUG: severity,domain,hash,comment:", block['severity'], block['domain'], block['digest'], block['comment'])
if block['severity'] == 'suspend':
+ # DEBUG: print(f"DEBUG: Adding entry='{entry}' with severity='{block['severity']}' ...")
json['reject'].append(entry)
elif block['severity'] == 'silence':
+ # DEBUG: print(f"DEBUG: Adding entry='{entry}' with severity='{block['severity']}' ...")
json['followers_only'].append(entry)
elif block['severity'] == 'reject_media':
+ # DEBUG: print(f"DEBUG: Adding entry='{entry}' with severity='{block['severity']}' ...")
json['media_removal'].append(entry)
elif block['severity'] == 'reject_reports':
+ # DEBUG: print(f"DEBUG: Adding entry='{entry}' with severity='{block['severity']}' ...")
json['report_removal'].append(entry)
else:
print("WARNING: Unknown severity:", block['severity'], block['domain'])
print("WARNING: block_level is empty, blocker:", blocker)
continue
+ # DEBUG: print(f"DEBUG: Checking {len(blocks)} entries from blocker='{blocker}',software='{software}',block_level='{block_level}' ...")
for instance in blocks:
blocked, blocked_hash, reason = instance.values()
# DEBUG: print("DEBUG: blocked,hash,reason:", blocked, blocked_hash, reason)
# DEBUG: print("DEBUG: Hash wasn't found, adding:", blocked, blocker)
fba.add_instance(blocked, blocker, origin, nodeinfo_url)
+ blocking = blocked if blocked.count("*") <= 1 else blocked_hash
+ # DEBUG: print(f"DEBUG: blocking='{blocking}',blocked='{blocked}',blocked_hash='{blocked_hash}'")
+
fba.cursor.execute(
"SELECT * FROM blocks WHERE blocker = ? AND blocked = ? AND block_level = ? LIMIT 1",
(
blocker,
- blocked if blocked.count("*") <= 1 else blocked_hash,
+ blocking,
block_level
),
)
if fba.cursor.fetchone() == None:
# DEBUG: print("DEBUG: Blocking:", blocker, blocked, block_level)
- fba.block_instance(blocker, blocked if blocked.count("*") <= 1 else blocked_hash, reason, block_level)
+ fba.block_instance(blocker, blocking, reason, block_level)
if block_level == "reject":
blockdict.append(
"reason" : reason
})
else:
- fba.update_last_seen(blocker, blocked if blocked.count("*") <= 1 else blocked_hash, block_level)
-
- if reason != "":
- # DEBUG: print("DEBUG: Updating block reason:", blocker, blocked, reason)
- fba.update_block_reason(reason, blocker, blocked if blocked.count("*") <= 1 else blocked_hash, block_level)
+ # DEBUG: print(f"DEBUG: Updating block last seen and reason for blocker='{blocker}',blocking='{blocking}' ...")
+ fba.update_last_seen(blocker, blocking, block_level)
+ fba.update_block_reason(reason, blocker, blocking, block_level)
fba.connection.commit()
except Exception as e:
print("WARNING: block_level is empty, blocker:", blocker)
continue
+ # DEBUG: print(f"DEBUG: Checking {len(blocks)} entries from blocker='{blocker}',software='{software}',block_level='{block_level}' ...")
for instance in blocks:
blocked, reason = instance.values()
# DEBUG: print("DEBUG: BEFORE blocked:", blocked)
fba.add_instance(blocked, blocker, origin, nodeinfo_url)
fba.cursor.execute(
- "SELECT * FROM blocks WHERE blocker = ? AND blocked = ? LIMIT 1",
- (blocker, blocked),
+ "SELECT * FROM blocks WHERE blocker = ? AND blocked = ? AND block_level = ? LIMIT 1",
+ (blocker, blocked, block_level),
)
if fba.cursor.fetchone() == None:
"reason" : reason
})
else:
+ print(f"DEBUG: Updating block last seen and reason for blocker='{blocker}',blocked='{blocked}' ...")
fba.update_last_seen(blocker, blocked, block_level)
-
- if reason != '':
- # DEBUG: print("DEBUG: Updating block reason:", blocker, blocked, reason)
fba.update_block_reason(reason, blocker, blocked, block_level)
fba.connection.commit()
"reason" : None
})
else:
+ print(f"DEBUG: Updating block last seen for blocker='{blocker}',blocked='{blocked}' ...")
fba.update_last_seen(blocker, blocked, "reject")
if "public_comment" in peer: