From e623e1cec078c4d77177a77758803b255f6f8c1c Mon Sep 17 00:00:00 2001 From: Alan Roberts Date: Sun, 1 Sep 2024 14:40:40 -0400 Subject: [PATCH] adding avatar, cover image, roles, reputations, and attitude to the settings exports --- app/user/routes.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/user/routes.py b/app/user/routes.py index abf7cb17..192910d4 100644 --- a/app/user/routes.py +++ b/app/user/routes.py @@ -240,10 +240,18 @@ def export_user_settings(user, admin_request=False): user_dict['markdown_editor'] = user.markdown_editor user_dict['interface_language'] = user.interface_language user_dict['reply_collapse_threshold'] = user.reply_collapse_threshold + if user.avatar_image() != '': + user_dict['avatar_image'] = f"https://{current_app.config['SERVER_NAME']}/{user.avatar_image()}" + if user.cover_image() != '': + user_dict['cover_image'] = f"https://{current_app.config['SERVER_NAME']}/{user.cover_image()}" # lemmy output compatibility user_dict['display_name'] = user.user_name user_dict['bio'] = user.about + if user.avatar_image() != '': + user_dict['avatar'] = f"https://{current_app.config['SERVER_NAME']}/{user.avatar_image()}" + if user.cover_image() != '': + user_dict['banner'] = f"https://{current_app.config['SERVER_NAME']}/{user.cover_image()}" user_dict['matrix_id'] = user.matrix_user_id user_dict['bot_account'] = user.bot user_dict['settings'] = { @@ -269,6 +277,14 @@ def export_user_settings(user, admin_request=False): user_dict['public_key'] = user.public_key user_dict['private_key'] = user.private_key + user_roles = [] + for r in user.roles.all(): + user_roles.append(r.name) + user_dict['roles'] = user_roles + + user_dict['reputation'] = user.reputation + user_dict['attitude'] = user.attitude + # setup the BytesIO buffer buffer = BytesIO() buffer.write(str(python_json.dumps(user_dict)).encode('utf-8'))