diff --git a/packetserver/runners/http_user_manager.py b/packetserver/runners/http_user_manager.py index 712f66f..97337ad 100644 --- a/packetserver/runners/http_user_manager.py +++ b/packetserver/runners/http_user_manager.py @@ -90,6 +90,10 @@ def main(): # list subparsers.add_parser("list", help="List all HTTP users") + # dump + p_dump = subparsers.add_parser("dump", help="Dump JSON details of the BBS user (incl. UUID and hidden flag)") + p_dump.add_argument("callsign", help="Callsign to dump") + args = parser.parse_args() # Open the database @@ -223,6 +227,38 @@ def main(): rf_status = "True" if user.is_rf_enabled(connection) else "False" print(f"{user.username:<12} {str(user.http_enabled):<13} {rf_status:<11} {created:<20} {last}") + 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)") + sys.exit(1) + + main_users = root.get('users', {}) + bbs_user = main_users.get(callsign) + if not bbs_user: + 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, + } + print(json.dumps(dump_data, indent=4)) finally: connection.close()