updated the dump.

This commit is contained in:
Michael Woods
2025-12-21 21:34:21 -05:00
parent cbe81c22aa
commit ba2e42db2d

View File

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