updated the dump.
This commit is contained in:
@@ -229,11 +229,11 @@ def main():
|
||||
|
||||
elif args.command == "dump":
|
||||
import json
|
||||
from packetserver.server.users import User # for type hint/reference
|
||||
|
||||
callsign = upper_callsign(args.callsign)
|
||||
if callsign not in users_mapping:
|
||||
print(f"Error: No HTTP user {callsign} found (dump only works for existing HTTP users)")
|
||||
http_user = users_mapping.get(callsign)
|
||||
if not http_user:
|
||||
print(f"Error: No HTTP user {callsign} found")
|
||||
sys.exit(1)
|
||||
|
||||
main_users = root.get('users', {})
|
||||
@@ -242,22 +242,30 @@ def main():
|
||||
print(f"Error: No corresponding BBS user {callsign} found")
|
||||
sys.exit(1)
|
||||
|
||||
# Build dict with key fields (extend as needed)
|
||||
dump_data = {
|
||||
"username": bbs_user.username,
|
||||
"uuid": str(bbs_user.uuid) if bbs_user.uuid else None,
|
||||
"hidden": bbs_user.hidden,
|
||||
"enabled": bbs_user.enabled,
|
||||
"created_at": time.strftime("%Y-%m-%d %H:%M:%S UTC", time.gmtime(bbs_user.created_at.timestamp())) if hasattr(
|
||||
bbs_user.created_at, "timestamp") else str(bbs_user.created_at),
|
||||
"last_seen": time.strftime("%Y-%m-%d %H:%M:%S UTC", time.gmtime(bbs_user.last_seen.timestamp())) if hasattr(
|
||||
bbs_user.last_seen, "timestamp") else str(bbs_user.last_seen),
|
||||
"bio": bbs_user.bio.strip() or None,
|
||||
"status": bbs_user.status.strip() or None,
|
||||
"email": bbs_user.email.strip() if bbs_user.email != " " else None,
|
||||
"location": bbs_user.location.strip() if bbs_user.location != " " else None,
|
||||
"socials": bbs_user.socials,
|
||||
"http_user": {
|
||||
"username": http_user.username,
|
||||
"http_enabled": http_user.http_enabled,
|
||||
"rf_enabled": http_user.is_rf_enabled(connection),
|
||||
"blacklisted": not http_user.is_rf_enabled(connection), # explicit inverse
|
||||
"created_at": time.strftime("%Y-%m-%d %H:%M:%S UTC", time.gmtime(http_user.created_at)),
|
||||
"failed_attempts": http_user.failed_attempts,
|
||||
},
|
||||
"bbs_user": {
|
||||
"username": bbs_user.username,
|
||||
"uuid": str(bbs_user.uuid) if hasattr(bbs_user, 'uuid') and bbs_user.uuid else None,
|
||||
"hidden": bbs_user.hidden,
|
||||
"enabled": bbs_user.enabled, # BBS enabled flag
|
||||
"created_at": time.strftime("%Y-%m-%d %H:%M:%S UTC", time.gmtime(bbs_user.created_at.timestamp())) if hasattr(bbs_user.created_at, "timestamp") else str(bbs_user.created_at),
|
||||
"last_seen": time.strftime("%Y-%m-%d %H:%M:%S UTC", time.gmtime(bbs_user.last_seen.timestamp())) if hasattr(bbs_user.last_seen, "timestamp") else str(bbs_user.last_seen),
|
||||
"bio": bbs_user.bio.strip() or None,
|
||||
"status": bbs_user.status.strip() or None,
|
||||
"email": bbs_user.email.strip() if bbs_user.email != " " else None,
|
||||
"location": bbs_user.location.strip() if bbs_user.location != " " else None,
|
||||
"socials": bbs_user.socials,
|
||||
}
|
||||
}
|
||||
|
||||
print(json.dumps(dump_data, indent=4))
|
||||
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user