From 6d2dc44c8a77a3b6de1bfb9240f05b9277cdd8bb Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 10 Dec 2022 10:34:49 +0000 Subject: [PATCH 1/4] Following port is integer --- importFollowing.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/importFollowing.py b/importFollowing.py index d8b4b4d86..1b8e0b5da 100644 --- a/importFollowing.py +++ b/importFollowing.py @@ -55,17 +55,21 @@ def _update_import_following(base_dir: str, main_session = None lines = following_str.split('\n') random.shuffle(lines) + print('FOLLOW: ' + handle + ' attempting to follow ' + str(lines)) nickname = handle.split('@')[0] domain = handle.split('@')[1] for line in lines: + if '://' not in line and '@' not in line: + continue + if ',' not in line: + continue orig_line = line notes = None line = line.strip() - if ',' in line: - fields = line.split(',') - line = fields[0].strip() - if len(fields) >= 5: - notes = fields[4] + fields = line.split(',') + line = fields[0].strip() + if len(fields) >= 5: + notes = fields[4] if line.startswith('#'): # comment continue @@ -111,8 +115,16 @@ def _update_import_following(base_dir: str, curr_http_prefix = httpd.http_prefix following_actor = following_handle if ':' in following_domain: - following_port = following_handle.split(':')[1] following_domain = following_domain.split(':')[0] + following_port = following_handle.split(':')[1] + if following_port.isdigit(): + following_port = int(following_port) + else: + if following_domain.endswith('.onion') or \ + following_domain.endswith('.i2p'): + following_port = 80 + else: + following_port = 443 # get the appropriate session curr_session = main_session From 9c60961a6e750a9ab139cac6dff0cb7412fc2659 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 10 Dec 2022 10:51:16 +0000 Subject: [PATCH 2/4] Debug --- importFollowing.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/importFollowing.py b/importFollowing.py index 1b8e0b5da..e8ce82deb 100644 --- a/importFollowing.py +++ b/importFollowing.py @@ -189,6 +189,8 @@ def _update_import_following(base_dir: str, except OSError: print('EX: unable to remove import 2 ' + line + ' from ' + import_filename) + print('FOLLOW: import sent follow to ' + line + + ' from ' + import_filename) return True return False From ed89a95cb579f090a3dc44b4aca7dbd1a4f34728 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 10 Dec 2022 11:05:03 +0000 Subject: [PATCH 3/4] Tidying --- importFollowing.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/importFollowing.py b/importFollowing.py index e8ce82deb..87eaf9825 100644 --- a/importFollowing.py +++ b/importFollowing.py @@ -10,6 +10,7 @@ __module_group__ = "Core" import os import time import random +from utils import get_full_domain from utils import acct_dir from utils import is_account_dir from utils import get_nickname_from_actor @@ -84,6 +85,8 @@ def _update_import_following(base_dir: str, # don't follow yourself continue following_handle = following_nickname + '@' + following_domain + following_handle_full = following_nickname + '@' + \ + get_full_domain(following_domain, following_port) if notes: notes = notes.replace('
', '\n') person_notes_filename = \ @@ -96,8 +99,8 @@ def _update_import_following(base_dir: str, except OSError: print('EX: Unable to import notes for ' + following_handle) - if is_following_actor(base_dir, - nickname, domain, following_handle): + if is_following_actor(base_dir, nickname, domain, + following_handle_full): # remove the followed handle from the import list following_str = following_str.replace(orig_line + '\n', '') try: @@ -114,17 +117,6 @@ def _update_import_following(base_dir: str, curr_port = httpd.port curr_http_prefix = httpd.http_prefix following_actor = following_handle - if ':' in following_domain: - following_domain = following_domain.split(':')[0] - following_port = following_handle.split(':')[1] - if following_port.isdigit(): - following_port = int(following_port) - else: - if following_domain.endswith('.onion') or \ - following_domain.endswith('.i2p'): - following_port = 80 - else: - following_port = 443 # get the appropriate session curr_session = main_session From 80fd77a1ce9e68040febd544e190ce52a3f48a56 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 10 Dec 2022 11:17:33 +0000 Subject: [PATCH 4/4] Avoid duplicated file extension --- content.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/content.py b/content.py index 0538699b7..a1320d4b7 100644 --- a/content.py +++ b/content.py @@ -1474,7 +1474,11 @@ def save_media_in_form_post(media_bytes, debug: bool, elif extension == 'wav4': extension = 'wav' if filename_base: - filename = filename_base + '.' + extension + if not filename_base.endswith('.' + extension): + filename = filename_base + '.' + extension + else: + # already has the extension + filename = filename_base search_lst = search_str.decode().split('/', maxsplit=1) attachment_media_type = \ search_lst[0].replace('Content-Type: ', '')