From cc4808d8dec675c6620ff19ee941ea1b02a180ed Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 10 Feb 2023 19:30:25 +0000 Subject: [PATCH] Importing follows --- daemon.py | 21 ++++++++++++++++++--- webapp_profile.py | 4 ++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/daemon.py b/daemon.py index a0faeb60a..7d34f3746 100644 --- a/daemon.py +++ b/daemon.py @@ -6176,7 +6176,7 @@ class PubServer(BaseHTTPRequestHandler): 'banner', 'search_banner', 'instanceLogo', 'left_col_image', 'right_col_image', - 'import_follows', + 'importFollows', 'import_theme' ) profile_media_types_uploaded = {} @@ -6221,7 +6221,7 @@ class PubServer(BaseHTTPRequestHandler): except OSError: print('EX: _profile_edit unable to delete ' + filename_base) - elif m_type == 'import_follows': + elif m_type == 'importFollows': filename_base = \ acct_dir(base_dir, nickname, domain) + \ '/import_following.csv' @@ -6241,7 +6241,7 @@ class PubServer(BaseHTTPRequestHandler): ' media, zip, csv or font filename in POST') continue - if m_type == 'import_follows': + if m_type == 'importFollows': if os.path.isfile(filename_base): print(nickname + ' imported follows csv') else: @@ -7832,6 +7832,21 @@ class PubServer(BaseHTTPRequestHandler): else: print('blocks not imported for ' + nickname) + if fields.get('importFollows'): + filename_base = \ + acct_dir(base_dir, nickname, domain) + \ + '/import_following.csv' + follows_str = fields['importFollows'] + while follows_str.startswith('\n'): + follows_str = follows_str[1:] + try: + with open(filename_base, 'w+', + encoding='utf-8') as fp_foll: + fp_foll.write(follows_str) + except OSError: + print('EX: unable to write imported follows ' + + filename_base) + # Save DM allowed instances list. # The allow list for incoming DMs, # if the .followDMs flag file exists diff --git a/webapp_profile.py b/webapp_profile.py index a54d5db5c..19c50fdc3 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -2281,8 +2281,8 @@ def _html_edit_profile_import_export(nickname: str, domain: str, edit_profile_form += \ '

\n' - edit_profile_form += '