mirror of https://gitlab.com/bashrc2/epicyon
				
				
				
			Merge branch 'main' of gitlab.com:bashrc2/epicyon
						commit
						74f571f995
					
				
							
								
								
									
										4
									
								
								cache.py
								
								
								
								
							
							
						
						
									
										4
									
								
								cache.py
								
								
								
								
							| 
						 | 
				
			
			@ -141,6 +141,7 @@ def get_person_pub_key(base_dir: str, session, person_url: str,
 | 
			
		|||
                       person_cache: {}, debug: bool,
 | 
			
		||||
                       project_version: str, http_prefix: str,
 | 
			
		||||
                       domain: str, onion_domain: str,
 | 
			
		||||
                       i2p_domain: str,
 | 
			
		||||
                       signing_priv_key_pem: str) -> str:
 | 
			
		||||
    if not person_url:
 | 
			
		||||
        return None
 | 
			
		||||
| 
						 | 
				
			
			@ -162,6 +163,9 @@ def get_person_pub_key(base_dir: str, session, person_url: str,
 | 
			
		|||
        if onion_domain:
 | 
			
		||||
            if '.onion/' in person_url:
 | 
			
		||||
                person_domain = onion_domain
 | 
			
		||||
        elif i2p_domain:
 | 
			
		||||
            if '.i2p/' in person_url:
 | 
			
		||||
                person_domain = i2p_domain
 | 
			
		||||
        profile_str = 'https://www.w3.org/ns/activitystreams'
 | 
			
		||||
        accept_str = \
 | 
			
		||||
            'application/activity+json; profile="' + profile_str + '"'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										35
									
								
								epicyon.py
								
								
								
								
							
							
						
						
									
										35
									
								
								epicyon.py
								
								
								
								
							| 
						 | 
				
			
			@ -1262,6 +1262,8 @@ if args.approve:
 | 
			
		|||
    if '@' not in args.approve:
 | 
			
		||||
        print('syntax: --approve nick@domain')
 | 
			
		||||
        sys.exit()
 | 
			
		||||
    session_onion = None
 | 
			
		||||
    session_i2p = None
 | 
			
		||||
    session = create_session(proxy_type)
 | 
			
		||||
    send_threads = []
 | 
			
		||||
    postLog = []
 | 
			
		||||
| 
						 | 
				
			
			@ -1272,8 +1274,19 @@ if args.approve:
 | 
			
		|||
    signing_priv_key_pem = None
 | 
			
		||||
    if args.secure_mode:
 | 
			
		||||
        signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
 | 
			
		||||
    manual_approve_follow_request(session, base_dir,
 | 
			
		||||
                                  http_prefix,
 | 
			
		||||
    onion_domain = get_config_param(base_dir, 'onionDomain')
 | 
			
		||||
    if args.onion:
 | 
			
		||||
        onion_domain = args.onion
 | 
			
		||||
    if onion_domain:
 | 
			
		||||
        session_onion = create_session('tor')
 | 
			
		||||
    i2p_domain = get_config_param(base_dir, 'i2pDomain')
 | 
			
		||||
    if args.i2p_domain:
 | 
			
		||||
        i2p_domain = args.i2p_domain
 | 
			
		||||
    if i2p_domain:
 | 
			
		||||
        session_i2p = create_session('i2p')
 | 
			
		||||
    manual_approve_follow_request(session, session_onion, session_i2p,
 | 
			
		||||
                                  onion_domain, i2p_domain,
 | 
			
		||||
                                  base_dir, http_prefix,
 | 
			
		||||
                                  args.nickname, domain, port,
 | 
			
		||||
                                  args.approve,
 | 
			
		||||
                                  federation_list,
 | 
			
		||||
| 
						 | 
				
			
			@ -1290,6 +1303,8 @@ if args.deny:
 | 
			
		|||
    if '@' not in args.deny:
 | 
			
		||||
        print('syntax: --deny nick@domain')
 | 
			
		||||
        sys.exit()
 | 
			
		||||
    session_onion = None
 | 
			
		||||
    session_i2p = None
 | 
			
		||||
    session = create_session(proxy_type)
 | 
			
		||||
    send_threads = []
 | 
			
		||||
    postLog = []
 | 
			
		||||
| 
						 | 
				
			
			@ -1300,8 +1315,19 @@ if args.deny:
 | 
			
		|||
    signing_priv_key_pem = None
 | 
			
		||||
    if args.secure_mode:
 | 
			
		||||
        signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
 | 
			
		||||
    manual_deny_follow_request(session, base_dir,
 | 
			
		||||
                               http_prefix,
 | 
			
		||||
    onion_domain = get_config_param(base_dir, 'onionDomain')
 | 
			
		||||
    if args.onion:
 | 
			
		||||
        onion_domain = args.onion
 | 
			
		||||
    if onion_domain:
 | 
			
		||||
        session_onion = create_session('tor')
 | 
			
		||||
    i2p_domain = get_config_param(base_dir, 'i2pDomain')
 | 
			
		||||
    if args.i2p_domain:
 | 
			
		||||
        i2p_domain = args.i2p_domain
 | 
			
		||||
    if i2p_domain:
 | 
			
		||||
        session_i2p = create_session('i2p')
 | 
			
		||||
    manual_deny_follow_request(session, session_onion, session_i2p,
 | 
			
		||||
                               onion_domain, i2p_domain,
 | 
			
		||||
                               base_dir, http_prefix,
 | 
			
		||||
                               args.nickname, domain, port,
 | 
			
		||||
                               args.deny,
 | 
			
		||||
                               federation_list,
 | 
			
		||||
| 
						 | 
				
			
			@ -3381,6 +3407,7 @@ if args.defaultCurrency:
 | 
			
		|||
        print('Default currency set to ' + args.defaultCurrency)
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    print('allowdeletion: ' + str(args.allowdeletion))
 | 
			
		||||
    run_daemon(crawlers_allowed,
 | 
			
		||||
               args.dyslexic_font,
 | 
			
		||||
               content_license_url,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -852,7 +852,8 @@ def followed_account_rejects(session, base_dir: str, http_prefix: str,
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
def send_follow_request(session, base_dir: str,
 | 
			
		||||
                        nickname: str, domain: str, port: int,
 | 
			
		||||
                        nickname: str, domain: str,
 | 
			
		||||
                        sender_domain: str, sender_port: int,
 | 
			
		||||
                        http_prefix: str,
 | 
			
		||||
                        follow_nickname: str, follow_domain: str,
 | 
			
		||||
                        followedActor: str,
 | 
			
		||||
| 
						 | 
				
			
			@ -870,7 +871,7 @@ def send_follow_request(session, base_dir: str,
 | 
			
		|||
        print('You are not permitted to follow the domain ' + follow_domain)
 | 
			
		||||
        return None
 | 
			
		||||
 | 
			
		||||
    full_domain = get_full_domain(domain, port)
 | 
			
		||||
    full_domain = get_full_domain(sender_domain, sender_port)
 | 
			
		||||
    follow_actor = local_actor_url(http_prefix, nickname, full_domain)
 | 
			
		||||
 | 
			
		||||
    request_domain = get_full_domain(follow_domain, followPort)
 | 
			
		||||
| 
						 | 
				
			
			@ -934,7 +935,7 @@ def send_follow_request(session, base_dir: str,
 | 
			
		|||
                                    follow_handle, debug)
 | 
			
		||||
 | 
			
		||||
    send_signed_json(new_follow_json, session, base_dir,
 | 
			
		||||
                     nickname, domain, port,
 | 
			
		||||
                     nickname, sender_domain, sender_port,
 | 
			
		||||
                     follow_nickname, follow_domain, followPort,
 | 
			
		||||
                     'https://www.w3.org/ns/activitystreams#Public',
 | 
			
		||||
                     http_prefix, True, client_to_server,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										190
									
								
								inbox.py
								
								
								
								
							
							
						
						
									
										190
									
								
								inbox.py
								
								
								
								
							| 
						 | 
				
			
			@ -459,7 +459,8 @@ def save_post_to_inbox_queue(base_dir: str, http_prefix: str,
 | 
			
		|||
                             message_bytes: str,
 | 
			
		||||
                             http_headers: {},
 | 
			
		||||
                             post_path: str, debug: bool,
 | 
			
		||||
                             blocked_cache: [], system_language: str) -> str:
 | 
			
		||||
                             blocked_cache: [], system_language: str,
 | 
			
		||||
                             mitm: bool) -> str:
 | 
			
		||||
    """Saves the given json to the inbox queue for the person
 | 
			
		||||
    key_id specifies the actor sending the post
 | 
			
		||||
    """
 | 
			
		||||
| 
						 | 
				
			
			@ -592,7 +593,8 @@ def save_post_to_inbox_queue(base_dir: str, http_prefix: str,
 | 
			
		|||
        'original': original_post_json_object,
 | 
			
		||||
        'digest': digest,
 | 
			
		||||
        'filename': filename,
 | 
			
		||||
        'destination': destination
 | 
			
		||||
        'destination': destination,
 | 
			
		||||
        'mitm': mitm
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if debug:
 | 
			
		||||
| 
						 | 
				
			
			@ -625,8 +627,12 @@ def _inbox_post_recipients_add(base_dir: str, http_prefix: str, toList: [],
 | 
			
		|||
                          handle + ' does not exist')
 | 
			
		||||
        else:
 | 
			
		||||
            if debug:
 | 
			
		||||
                print('DEBUG: ' + recipient + ' is not local to ' +
 | 
			
		||||
                      domain_match)
 | 
			
		||||
                if recipient.endswith('#Public'):
 | 
			
		||||
                    print('DEBUG: #Public recipient is too non-specific. ' +
 | 
			
		||||
                          recipient + ' ' + domain_match)
 | 
			
		||||
                else:
 | 
			
		||||
                    print('DEBUG: ' + recipient + ' is not local to ' +
 | 
			
		||||
                          domain_match)
 | 
			
		||||
                print(str(toList))
 | 
			
		||||
        if recipient.endswith('followers'):
 | 
			
		||||
            if debug:
 | 
			
		||||
| 
						 | 
				
			
			@ -1824,7 +1830,8 @@ def _receive_delete(session, handle: str, is_group: bool, base_dir: str,
 | 
			
		|||
def _receive_announce(recent_posts_cache: {},
 | 
			
		||||
                      session, handle: str, is_group: bool, base_dir: str,
 | 
			
		||||
                      http_prefix: str,
 | 
			
		||||
                      domain: str, onion_domain: str, port: int,
 | 
			
		||||
                      domain: str,
 | 
			
		||||
                      onion_domain: str, i2p_domain: str, port: int,
 | 
			
		||||
                      send_threads: [], post_log: [], cached_webfingers: {},
 | 
			
		||||
                      person_cache: {}, message_json: {}, federation_list: [],
 | 
			
		||||
                      debug: bool, translate: {},
 | 
			
		||||
| 
						 | 
				
			
			@ -2034,6 +2041,7 @@ def _receive_announce(recent_posts_cache: {},
 | 
			
		|||
                                           person_cache, debug,
 | 
			
		||||
                                           __version__, http_prefix,
 | 
			
		||||
                                           domain, onion_domain,
 | 
			
		||||
                                           i2p_domain,
 | 
			
		||||
                                           signing_priv_key_pem)
 | 
			
		||||
                    if pub_key:
 | 
			
		||||
                        if debug:
 | 
			
		||||
| 
						 | 
				
			
			@ -2322,6 +2330,7 @@ def _valid_post_content(base_dir: str, nickname: str, domain: str,
 | 
			
		|||
 | 
			
		||||
def _obtain_avatar_for_reply_post(session, base_dir: str, http_prefix: str,
 | 
			
		||||
                                  domain: str, onion_domain: str,
 | 
			
		||||
                                  i2p_domain: str,
 | 
			
		||||
                                  person_cache: {},
 | 
			
		||||
                                  post_json_object: {}, debug: bool,
 | 
			
		||||
                                  signing_priv_key_pem: str) -> None:
 | 
			
		||||
| 
						 | 
				
			
			@ -2355,7 +2364,8 @@ def _obtain_avatar_for_reply_post(session, base_dir: str, http_prefix: str,
 | 
			
		|||
            get_person_pub_key(base_dir, session, lookup_actor,
 | 
			
		||||
                               person_cache, debug,
 | 
			
		||||
                               __version__, http_prefix,
 | 
			
		||||
                               domain, onion_domain, signing_priv_key_pem)
 | 
			
		||||
                               domain, onion_domain, i2p_domain,
 | 
			
		||||
                               signing_priv_key_pem)
 | 
			
		||||
        if pub_key:
 | 
			
		||||
            if debug:
 | 
			
		||||
                print('DEBUG: public key obtained for reply: ' + lookup_actor)
 | 
			
		||||
| 
						 | 
				
			
			@ -2637,7 +2647,8 @@ def _group_handle(base_dir: str, handle: str) -> bool:
 | 
			
		|||
    return actor_json['type'] == 'Group'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def _send_to_group_members(session, base_dir: str, handle: str, port: int,
 | 
			
		||||
def _send_to_group_members(session, session_onion, session_i2p,
 | 
			
		||||
                           base_dir: str, handle: str, port: int,
 | 
			
		||||
                           post_json_object: {},
 | 
			
		||||
                           http_prefix: str, federation_list: [],
 | 
			
		||||
                           send_threads: [], post_log: [],
 | 
			
		||||
| 
						 | 
				
			
			@ -2698,7 +2709,8 @@ def _send_to_group_members(session, base_dir: str, handle: str, port: int,
 | 
			
		|||
                        person_cache, cached_webfingers,
 | 
			
		||||
                        debug, __version__, signing_priv_key_pem)
 | 
			
		||||
 | 
			
		||||
    send_to_followers_thread(session, base_dir, nickname, domain,
 | 
			
		||||
    send_to_followers_thread(session, session_onion, session_i2p,
 | 
			
		||||
                             base_dir, nickname, domain,
 | 
			
		||||
                             onion_domain, i2p_domain, port,
 | 
			
		||||
                             http_prefix, federation_list,
 | 
			
		||||
                             send_threads, post_log,
 | 
			
		||||
| 
						 | 
				
			
			@ -3023,8 +3035,8 @@ def _is_valid_dm(base_dir: str, nickname: str, domain: str, port: int,
 | 
			
		|||
def _receive_question_vote(base_dir: str, nickname: str, domain: str,
 | 
			
		||||
                           http_prefix: str, handle: str, debug: bool,
 | 
			
		||||
                           post_json_object: {}, recent_posts_cache: {},
 | 
			
		||||
                           session, onion_domain: str,
 | 
			
		||||
                           i2p_domain: str, port: int,
 | 
			
		||||
                           session, session_onion, session_i2p,
 | 
			
		||||
                           onion_domain: str, i2p_domain: str, port: int,
 | 
			
		||||
                           federation_list: [], send_threads: [], post_log: [],
 | 
			
		||||
                           cached_webfingers: {}, person_cache: {},
 | 
			
		||||
                           signing_priv_key_pem: str,
 | 
			
		||||
| 
						 | 
				
			
			@ -3100,7 +3112,8 @@ def _receive_question_vote(base_dir: str, nickname: str, domain: str,
 | 
			
		|||
    question_json['type'] = 'Update'
 | 
			
		||||
    shared_items_federated_domains = []
 | 
			
		||||
    shared_item_federation_tokens = {}
 | 
			
		||||
    send_to_followers_thread(session, base_dir, nickname, domain,
 | 
			
		||||
    send_to_followers_thread(session, session_onion, session_i2p,
 | 
			
		||||
                             base_dir, nickname, domain,
 | 
			
		||||
                             onion_domain, i2p_domain, port,
 | 
			
		||||
                             http_prefix, federation_list,
 | 
			
		||||
                             send_threads, post_log,
 | 
			
		||||
| 
						 | 
				
			
			@ -3228,7 +3241,8 @@ def _check_for_git_patches(base_dir: str, nickname: str, domain: str,
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
def _inbox_after_initial(recent_posts_cache: {}, max_recent_posts: int,
 | 
			
		||||
                         session, key_id: str, handle: str, message_json: {},
 | 
			
		||||
                         session, session_onion, session_i2p,
 | 
			
		||||
                         key_id: str, handle: str, message_json: {},
 | 
			
		||||
                         base_dir: str, http_prefix: str, send_threads: [],
 | 
			
		||||
                         post_log: [], cached_webfingers: {}, person_cache: {},
 | 
			
		||||
                         queue: [], domain: str,
 | 
			
		||||
| 
						 | 
				
			
			@ -3403,7 +3417,7 @@ def _inbox_after_initial(recent_posts_cache: {}, max_recent_posts: int,
 | 
			
		|||
    if _receive_announce(recent_posts_cache,
 | 
			
		||||
                         session, handle, is_group,
 | 
			
		||||
                         base_dir, http_prefix,
 | 
			
		||||
                         domain, onion_domain, port,
 | 
			
		||||
                         domain, onion_domain, i2p_domain, port,
 | 
			
		||||
                         send_threads, post_log,
 | 
			
		||||
                         cached_webfingers,
 | 
			
		||||
                         person_cache,
 | 
			
		||||
| 
						 | 
				
			
			@ -3503,7 +3517,8 @@ def _inbox_after_initial(recent_posts_cache: {}, max_recent_posts: int,
 | 
			
		|||
        _receive_question_vote(base_dir, nickname, domain,
 | 
			
		||||
                               http_prefix, handle, debug,
 | 
			
		||||
                               post_json_object, recent_posts_cache,
 | 
			
		||||
                               session, onion_domain, i2p_domain, port,
 | 
			
		||||
                               session, session_onion, session_i2p,
 | 
			
		||||
                               onion_domain, i2p_domain, port,
 | 
			
		||||
                               federation_list, send_threads, post_log,
 | 
			
		||||
                               cached_webfingers, person_cache,
 | 
			
		||||
                               signing_priv_key_pem,
 | 
			
		||||
| 
						 | 
				
			
			@ -3565,7 +3580,8 @@ def _inbox_after_initial(recent_posts_cache: {}, max_recent_posts: int,
 | 
			
		|||
 | 
			
		||||
        # get the avatar for a reply/announce
 | 
			
		||||
        _obtain_avatar_for_reply_post(session, base_dir,
 | 
			
		||||
                                      http_prefix, domain, onion_domain,
 | 
			
		||||
                                      http_prefix, domain,
 | 
			
		||||
                                      onion_domain, i2p_domain,
 | 
			
		||||
                                      person_cache, post_json_object, debug,
 | 
			
		||||
                                      signing_priv_key_pem)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -3668,7 +3684,8 @@ def _inbox_after_initial(recent_posts_cache: {}, max_recent_posts: int,
 | 
			
		|||
 | 
			
		||||
            # send the post out to group members
 | 
			
		||||
            if is_group:
 | 
			
		||||
                _send_to_group_members(session, base_dir, handle, port,
 | 
			
		||||
                _send_to_group_members(session, session_onion, session_i2p,
 | 
			
		||||
                                       base_dir, handle, port,
 | 
			
		||||
                                       post_json_object,
 | 
			
		||||
                                       http_prefix, federation_list,
 | 
			
		||||
                                       send_threads,
 | 
			
		||||
| 
						 | 
				
			
			@ -3909,13 +3926,14 @@ def _check_json_signature(base_dir: str, queue_json: {}) -> (bool, bool):
 | 
			
		|||
    return has_json_signature, jwebsig_type
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def _receive_follow_request(session, base_dir: str, http_prefix: str,
 | 
			
		||||
def _receive_follow_request(session, session_onion, session_i2p,
 | 
			
		||||
                            base_dir: str, http_prefix: str,
 | 
			
		||||
                            port: int, send_threads: [], post_log: [],
 | 
			
		||||
                            cached_webfingers: {}, person_cache: {},
 | 
			
		||||
                            message_json: {}, federation_list: [],
 | 
			
		||||
                            debug: bool, project_version: str,
 | 
			
		||||
                            max_followers: int, onion_domain: str,
 | 
			
		||||
                            signing_priv_key_pem: str,
 | 
			
		||||
                            i2p_domain: str, signing_priv_key_pem: str,
 | 
			
		||||
                            unit_test: bool) -> bool:
 | 
			
		||||
    """Receives a follow request within the POST section of HTTPServer
 | 
			
		||||
    """
 | 
			
		||||
| 
						 | 
				
			
			@ -3995,8 +4013,23 @@ def _receive_follow_request(session, base_dir: str, http_prefix: str,
 | 
			
		|||
 | 
			
		||||
    approve_handle = nickname + '@' + domain_full
 | 
			
		||||
 | 
			
		||||
    curr_session = session
 | 
			
		||||
    curr_http_prefix = http_prefix
 | 
			
		||||
    curr_domain = domain
 | 
			
		||||
    curr_port = from_port
 | 
			
		||||
    if onion_domain and domain_to_follow.endswith('.onion'):
 | 
			
		||||
        curr_session = session_onion
 | 
			
		||||
        curr_http_prefix = 'http'
 | 
			
		||||
        curr_domain = onion_domain
 | 
			
		||||
        curr_port = 80
 | 
			
		||||
    elif i2p_domain and domain_to_follow.endswith('.i2p'):
 | 
			
		||||
        curr_session = session_i2p
 | 
			
		||||
        curr_http_prefix = 'http'
 | 
			
		||||
        curr_domain = i2p_domain
 | 
			
		||||
        curr_port = 80
 | 
			
		||||
 | 
			
		||||
    # is the actor sending the request valid?
 | 
			
		||||
    if not valid_sending_actor(session, base_dir,
 | 
			
		||||
    if not valid_sending_actor(curr_session, base_dir,
 | 
			
		||||
                               nickname_to_follow, domain_to_follow,
 | 
			
		||||
                               person_cache, message_json,
 | 
			
		||||
                               signing_priv_key_pem, debug, unit_test):
 | 
			
		||||
| 
						 | 
				
			
			@ -4033,10 +4066,12 @@ def _receive_follow_request(session, base_dir: str, http_prefix: str,
 | 
			
		|||
        # Getting their public key has the same result
 | 
			
		||||
        if debug:
 | 
			
		||||
            print('Obtaining the following actor: ' + message_json['actor'])
 | 
			
		||||
        if not get_person_pub_key(base_dir, session, message_json['actor'],
 | 
			
		||||
        if not get_person_pub_key(base_dir, curr_session,
 | 
			
		||||
                                  message_json['actor'],
 | 
			
		||||
                                  person_cache, debug, project_version,
 | 
			
		||||
                                  http_prefix, domain_to_follow, onion_domain,
 | 
			
		||||
                                  signing_priv_key_pem):
 | 
			
		||||
                                  curr_http_prefix,
 | 
			
		||||
                                  domain_to_follow, onion_domain,
 | 
			
		||||
                                  i2p_domain, signing_priv_key_pem):
 | 
			
		||||
            if debug:
 | 
			
		||||
                print('Unable to obtain following actor: ' +
 | 
			
		||||
                      message_json['actor'])
 | 
			
		||||
| 
						 | 
				
			
			@ -4071,10 +4106,12 @@ def _receive_follow_request(session, base_dir: str, http_prefix: str,
 | 
			
		|||
            if debug:
 | 
			
		||||
                print('Obtaining the following actor: ' +
 | 
			
		||||
                      message_json['actor'])
 | 
			
		||||
            if not get_person_pub_key(base_dir, session, message_json['actor'],
 | 
			
		||||
            if not get_person_pub_key(base_dir, curr_session,
 | 
			
		||||
                                      message_json['actor'],
 | 
			
		||||
                                      person_cache, debug, project_version,
 | 
			
		||||
                                      http_prefix, domain_to_follow,
 | 
			
		||||
                                      onion_domain, signing_priv_key_pem):
 | 
			
		||||
                                      curr_http_prefix, domain_to_follow,
 | 
			
		||||
                                      onion_domain, i2p_domain,
 | 
			
		||||
                                      signing_priv_key_pem):
 | 
			
		||||
                if debug:
 | 
			
		||||
                    print('Unable to obtain following actor: ' +
 | 
			
		||||
                          message_json['actor'])
 | 
			
		||||
| 
						 | 
				
			
			@ -4116,9 +4153,9 @@ def _receive_follow_request(session, base_dir: str, http_prefix: str,
 | 
			
		|||
                    print('EX: unable to write ' + followers_filename)
 | 
			
		||||
 | 
			
		||||
    print('Beginning follow accept')
 | 
			
		||||
    return followed_account_accepts(session, base_dir, http_prefix,
 | 
			
		||||
    return followed_account_accepts(curr_session, base_dir, curr_http_prefix,
 | 
			
		||||
                                    nickname_to_follow, domain_to_follow, port,
 | 
			
		||||
                                    nickname, domain, from_port,
 | 
			
		||||
                                    nickname, curr_domain, curr_port,
 | 
			
		||||
                                    message_json['actor'], federation_list,
 | 
			
		||||
                                    message_json, send_threads, post_log,
 | 
			
		||||
                                    cached_webfingers, person_cache,
 | 
			
		||||
| 
						 | 
				
			
			@ -4153,10 +4190,30 @@ def run_inbox_queue(recent_posts_cache: {}, max_recent_posts: int,
 | 
			
		|||
    """Processes received items and moves them to the appropriate
 | 
			
		||||
    directories
 | 
			
		||||
    """
 | 
			
		||||
    curr_session_time = int(time.time())
 | 
			
		||||
    session_last_update = curr_session_time
 | 
			
		||||
    print('Starting new session when starting inbox queue')
 | 
			
		||||
    curr_session_time = int(time.time())
 | 
			
		||||
    session_last_update = 0
 | 
			
		||||
    session = create_session(proxy_type)
 | 
			
		||||
    if session:
 | 
			
		||||
        session_last_update = curr_session_time
 | 
			
		||||
 | 
			
		||||
    # is this is a clearnet instance then optionally start sessions
 | 
			
		||||
    # for onion and i2p domains
 | 
			
		||||
    session_onion = None
 | 
			
		||||
    session_i2p = None
 | 
			
		||||
    session_last_update_onion = 0
 | 
			
		||||
    session_last_update_i2p = 0
 | 
			
		||||
    if proxy_type != 'tor' and onion_domain:
 | 
			
		||||
        print('Starting onion session when starting inbox queue')
 | 
			
		||||
        session_onion = create_session('tor')
 | 
			
		||||
        if session_onion:
 | 
			
		||||
            session_onion = curr_session_time
 | 
			
		||||
    if proxy_type != 'i2p' and i2p_domain:
 | 
			
		||||
        print('Starting i2p session when starting inbox queue')
 | 
			
		||||
        session_i2p = create_session('i2p')
 | 
			
		||||
        if session_i2p:
 | 
			
		||||
            session_i2p = curr_session_time
 | 
			
		||||
 | 
			
		||||
    inbox_handle = 'inbox@' + domain
 | 
			
		||||
    if debug:
 | 
			
		||||
        print('DEBUG: Inbox queue running')
 | 
			
		||||
| 
						 | 
				
			
			@ -4209,16 +4266,6 @@ def run_inbox_queue(recent_posts_cache: {}, max_recent_posts: int,
 | 
			
		|||
                _restore_queue_items(base_dir, queue)
 | 
			
		||||
            continue
 | 
			
		||||
 | 
			
		||||
        curr_time = int(time.time())
 | 
			
		||||
 | 
			
		||||
        # recreate the session periodically
 | 
			
		||||
        if not session or curr_time - session_last_update > 21600:
 | 
			
		||||
            print('Regenerating inbox queue session at 6hr interval')
 | 
			
		||||
            session = create_session(proxy_type)
 | 
			
		||||
            if not session:
 | 
			
		||||
                continue
 | 
			
		||||
            session_last_update = curr_time
 | 
			
		||||
 | 
			
		||||
        # oldest item first
 | 
			
		||||
        queue.sort()
 | 
			
		||||
        queue_filename = queue[0]
 | 
			
		||||
| 
						 | 
				
			
			@ -4249,6 +4296,8 @@ def run_inbox_queue(recent_posts_cache: {}, max_recent_posts: int,
 | 
			
		|||
                          str(queue_filename))
 | 
			
		||||
            continue
 | 
			
		||||
 | 
			
		||||
        curr_time = int(time.time())
 | 
			
		||||
 | 
			
		||||
        # clear the daily quotas for maximum numbers of received posts
 | 
			
		||||
        if curr_time - quotas_last_update_daily > 60 * 60 * 24:
 | 
			
		||||
            quotas_daily = {
 | 
			
		||||
| 
						 | 
				
			
			@ -4276,6 +4325,49 @@ def run_inbox_queue(recent_posts_cache: {}, max_recent_posts: int,
 | 
			
		|||
                                 account_max_posts_per_day, debug):
 | 
			
		||||
            continue
 | 
			
		||||
 | 
			
		||||
        # recreate the session periodically
 | 
			
		||||
        if not session or curr_time - session_last_update > 21600:
 | 
			
		||||
            print('Regenerating inbox queue session at 6hr interval')
 | 
			
		||||
            session = create_session(proxy_type)
 | 
			
		||||
            if session:
 | 
			
		||||
                session_last_update = curr_time
 | 
			
		||||
            else:
 | 
			
		||||
                print('WARN: inbox session not created')
 | 
			
		||||
                continue
 | 
			
		||||
        if onion_domain:
 | 
			
		||||
            if not session_onion or \
 | 
			
		||||
               curr_time - session_last_update_onion > 21600:
 | 
			
		||||
                print('Regenerating inbox queue onion session at 6hr interval')
 | 
			
		||||
                session_onion = create_session('tor')
 | 
			
		||||
                if session_onion:
 | 
			
		||||
                    session_last_update_onion = curr_time
 | 
			
		||||
                else:
 | 
			
		||||
                    print('WARN: inbox onion session not created')
 | 
			
		||||
                    continue
 | 
			
		||||
        if i2p_domain:
 | 
			
		||||
            if not session_i2p or curr_time - session_last_update_i2p > 21600:
 | 
			
		||||
                print('Regenerating inbox queue i2p session at 6hr interval')
 | 
			
		||||
                session_i2p = create_session('i2p')
 | 
			
		||||
                if session_i2p:
 | 
			
		||||
                    session_last_update_i2p = curr_time
 | 
			
		||||
                else:
 | 
			
		||||
                    print('WARN: inbox i2p session not created')
 | 
			
		||||
                    continue
 | 
			
		||||
 | 
			
		||||
        curr_session = session
 | 
			
		||||
        curr_proxy_type = proxy_type
 | 
			
		||||
        if queue_json.get('actor'):
 | 
			
		||||
            if isinstance(queue_json['actor'], str):
 | 
			
		||||
                sender_domain, _ = get_domain_from_actor(queue_json['actor'])
 | 
			
		||||
                if sender_domain.endswith('.onion') and \
 | 
			
		||||
                   session_onion and proxy_type != 'tor':
 | 
			
		||||
                    curr_proxy_type = 'tor'
 | 
			
		||||
                    curr_session = session_onion
 | 
			
		||||
                elif (sender_domain.endswith('.i2p') and
 | 
			
		||||
                      session_i2p and proxy_type != 'i2p'):
 | 
			
		||||
                    curr_proxy_type = 'i2p'
 | 
			
		||||
                    curr_session = session_i2p
 | 
			
		||||
 | 
			
		||||
        if debug and queue_json.get('actor'):
 | 
			
		||||
            print('Obtaining public key for actor ' + queue_json['actor'])
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -4298,10 +4390,11 @@ def run_inbox_queue(recent_posts_cache: {}, max_recent_posts: int,
 | 
			
		|||
                break
 | 
			
		||||
 | 
			
		||||
            pub_key = \
 | 
			
		||||
                get_person_pub_key(base_dir, session, key_id,
 | 
			
		||||
                get_person_pub_key(base_dir, curr_session, key_id,
 | 
			
		||||
                                   person_cache, debug,
 | 
			
		||||
                                   project_version, http_prefix,
 | 
			
		||||
                                   domain, onion_domain, signing_priv_key_pem)
 | 
			
		||||
                                   domain, onion_domain, i2p_domain,
 | 
			
		||||
                                   signing_priv_key_pem)
 | 
			
		||||
            if pub_key:
 | 
			
		||||
                if debug:
 | 
			
		||||
                    print('DEBUG: public key: ' + str(pub_key))
 | 
			
		||||
| 
						 | 
				
			
			@ -4409,7 +4502,7 @@ def run_inbox_queue(recent_posts_cache: {}, max_recent_posts: int,
 | 
			
		|||
        # if queue_json['post'].get('id'):
 | 
			
		||||
        #     queue_json['post']['id'] = queue_json['id']
 | 
			
		||||
 | 
			
		||||
        if _receive_undo(session,
 | 
			
		||||
        if _receive_undo(curr_session,
 | 
			
		||||
                         base_dir, http_prefix, port,
 | 
			
		||||
                         send_threads, post_log,
 | 
			
		||||
                         cached_webfingers,
 | 
			
		||||
| 
						 | 
				
			
			@ -4430,7 +4523,7 @@ def run_inbox_queue(recent_posts_cache: {}, max_recent_posts: int,
 | 
			
		|||
 | 
			
		||||
        if debug:
 | 
			
		||||
            print('DEBUG: checking for follow requests')
 | 
			
		||||
        if _receive_follow_request(session,
 | 
			
		||||
        if _receive_follow_request(curr_session, session_onion, session_i2p,
 | 
			
		||||
                                   base_dir, http_prefix, port,
 | 
			
		||||
                                   send_threads, post_log,
 | 
			
		||||
                                   cached_webfingers,
 | 
			
		||||
| 
						 | 
				
			
			@ -4438,7 +4531,7 @@ def run_inbox_queue(recent_posts_cache: {}, max_recent_posts: int,
 | 
			
		|||
                                   queue_json['post'],
 | 
			
		||||
                                   federation_list,
 | 
			
		||||
                                   debug, project_version,
 | 
			
		||||
                                   max_followers, onion_domain,
 | 
			
		||||
                                   max_followers, onion_domain, i2p_domain,
 | 
			
		||||
                                   signing_priv_key_pem, unit_test):
 | 
			
		||||
            if os.path.isfile(queue_filename):
 | 
			
		||||
                try:
 | 
			
		||||
| 
						 | 
				
			
			@ -4455,7 +4548,7 @@ def run_inbox_queue(recent_posts_cache: {}, max_recent_posts: int,
 | 
			
		|||
            if debug:
 | 
			
		||||
                print('DEBUG: No follow requests')
 | 
			
		||||
 | 
			
		||||
        if receive_accept_reject(session,
 | 
			
		||||
        if receive_accept_reject(curr_session,
 | 
			
		||||
                                 base_dir, http_prefix, domain, port,
 | 
			
		||||
                                 send_threads, post_log,
 | 
			
		||||
                                 cached_webfingers, person_cache,
 | 
			
		||||
| 
						 | 
				
			
			@ -4472,7 +4565,7 @@ def run_inbox_queue(recent_posts_cache: {}, max_recent_posts: int,
 | 
			
		|||
                queue.pop(0)
 | 
			
		||||
            continue
 | 
			
		||||
 | 
			
		||||
        if _receive_update_activity(recent_posts_cache, session,
 | 
			
		||||
        if _receive_update_activity(recent_posts_cache, curr_session,
 | 
			
		||||
                                    base_dir, http_prefix,
 | 
			
		||||
                                    domain, port,
 | 
			
		||||
                                    send_threads, post_log,
 | 
			
		||||
| 
						 | 
				
			
			@ -4555,7 +4648,8 @@ def run_inbox_queue(recent_posts_cache: {}, max_recent_posts: int,
 | 
			
		|||
            languages_understood = []
 | 
			
		||||
            _inbox_after_initial(recent_posts_cache,
 | 
			
		||||
                                 max_recent_posts,
 | 
			
		||||
                                 session, key_id, handle,
 | 
			
		||||
                                 session, session_onion, session_i2p,
 | 
			
		||||
                                 key_id, handle,
 | 
			
		||||
                                 queue_json['post'],
 | 
			
		||||
                                 base_dir, http_prefix,
 | 
			
		||||
                                 send_threads, post_log,
 | 
			
		||||
| 
						 | 
				
			
			@ -4563,7 +4657,7 @@ def run_inbox_queue(recent_posts_cache: {}, max_recent_posts: int,
 | 
			
		|||
                                 person_cache, queue,
 | 
			
		||||
                                 domain,
 | 
			
		||||
                                 onion_domain, i2p_domain,
 | 
			
		||||
                                 port, proxy_type,
 | 
			
		||||
                                 port, curr_proxy_type,
 | 
			
		||||
                                 federation_list,
 | 
			
		||||
                                 debug,
 | 
			
		||||
                                 queue_filename, destination,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,8 +19,9 @@ from utils import acct_dir
 | 
			
		|||
from threads import thread_with_trace
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def manual_deny_follow_request(session, base_dir: str,
 | 
			
		||||
                               http_prefix: str,
 | 
			
		||||
def manual_deny_follow_request(session, session_onion, session_i2p,
 | 
			
		||||
                               onion_domain: str, i2p_domain: str,
 | 
			
		||||
                               base_dir: str, http_prefix: str,
 | 
			
		||||
                               nickname: str, domain: str, port: int,
 | 
			
		||||
                               deny_handle: str,
 | 
			
		||||
                               federation_list: [],
 | 
			
		||||
| 
						 | 
				
			
			@ -59,7 +60,9 @@ def manual_deny_follow_request(session, base_dir: str,
 | 
			
		|||
    if ':' in deny_domain:
 | 
			
		||||
        deny_port = get_port_from_domain(deny_domain)
 | 
			
		||||
        deny_domain = remove_domain_port(deny_domain)
 | 
			
		||||
    followed_account_rejects(session, base_dir, http_prefix,
 | 
			
		||||
    followed_account_rejects(session, session_onion, session_i2p,
 | 
			
		||||
                             onion_domain, i2p_domain,
 | 
			
		||||
                             base_dir, http_prefix,
 | 
			
		||||
                             nickname, domain, port,
 | 
			
		||||
                             deny_nickname, deny_domain, deny_port,
 | 
			
		||||
                             federation_list,
 | 
			
		||||
| 
						 | 
				
			
			@ -71,8 +74,9 @@ def manual_deny_follow_request(session, base_dir: str,
 | 
			
		|||
    print('Follow request from ' + deny_handle + ' was denied.')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def manual_deny_follow_request_thread(session, base_dir: str,
 | 
			
		||||
                                      http_prefix: str,
 | 
			
		||||
def manual_deny_follow_request_thread(session, session_onion, session_i2p,
 | 
			
		||||
                                      onion_domain: str, i2p_domain: str,
 | 
			
		||||
                                      base_dir: str, http_prefix: str,
 | 
			
		||||
                                      nickname: str, domain: str, port: int,
 | 
			
		||||
                                      deny_handle: str,
 | 
			
		||||
                                      federation_list: [],
 | 
			
		||||
| 
						 | 
				
			
			@ -86,8 +90,9 @@ def manual_deny_follow_request_thread(session, base_dir: str,
 | 
			
		|||
    """
 | 
			
		||||
    thr = \
 | 
			
		||||
        thread_with_trace(target=manual_deny_follow_request,
 | 
			
		||||
                          args=(session, base_dir,
 | 
			
		||||
                                http_prefix,
 | 
			
		||||
                          args=(session, session_onion, session_i2p,
 | 
			
		||||
                                onion_domain, i2p_domain,
 | 
			
		||||
                                base_dir, http_prefix,
 | 
			
		||||
                                nickname, domain, port,
 | 
			
		||||
                                deny_handle,
 | 
			
		||||
                                federation_list,
 | 
			
		||||
| 
						 | 
				
			
			@ -120,8 +125,9 @@ def _approve_follower_handle(account_dir: str, approve_handle: str) -> None:
 | 
			
		|||
            print('EX: unable to write ' + approved_filename)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def manual_approve_follow_request(session, base_dir: str,
 | 
			
		||||
                                  http_prefix: str,
 | 
			
		||||
def manual_approve_follow_request(session, session_onion, session_i2p,
 | 
			
		||||
                                  onion_domain: str, i2p_domain: str,
 | 
			
		||||
                                  base_dir: str, http_prefix: str,
 | 
			
		||||
                                  nickname: str, domain: str, port: int,
 | 
			
		||||
                                  approve_handle: str,
 | 
			
		||||
                                  federation_list: [],
 | 
			
		||||
| 
						 | 
				
			
			@ -206,12 +212,31 @@ def manual_approve_follow_request(session, base_dir: str,
 | 
			
		|||
                                    get_port_from_domain(approve_domain)
 | 
			
		||||
                                approve_domain = \
 | 
			
		||||
                                    remove_domain_port(approve_domain)
 | 
			
		||||
 | 
			
		||||
                            curr_domain = domain
 | 
			
		||||
                            curr_port = port
 | 
			
		||||
                            curr_session = session
 | 
			
		||||
                            curr_http_prefix = http_prefix
 | 
			
		||||
                            if onion_domain and \
 | 
			
		||||
                               approve_domain.endswith('.onion'):
 | 
			
		||||
                                curr_domain = onion_domain
 | 
			
		||||
                                curr_port = 80
 | 
			
		||||
                                curr_session = session_onion
 | 
			
		||||
                                curr_http_prefix = 'http'
 | 
			
		||||
                            elif (i2p_domain and
 | 
			
		||||
                                  approve_domain.endswith('.i2p')):
 | 
			
		||||
                                curr_domain = i2p_domain
 | 
			
		||||
                                curr_port = 80
 | 
			
		||||
                                curr_session = session_i2p
 | 
			
		||||
                                curr_http_prefix = 'http'
 | 
			
		||||
 | 
			
		||||
                            print('Manual follow accept: Sending Accept for ' +
 | 
			
		||||
                                  handle + ' follow request from ' +
 | 
			
		||||
                                  approve_nickname + '@' + approve_domain)
 | 
			
		||||
                            followed_account_accepts(session, base_dir,
 | 
			
		||||
                                                     http_prefix,
 | 
			
		||||
                                                     nickname, domain, port,
 | 
			
		||||
                            followed_account_accepts(curr_session, base_dir,
 | 
			
		||||
                                                     curr_http_prefix,
 | 
			
		||||
                                                     nickname,
 | 
			
		||||
                                                     curr_domain, curr_port,
 | 
			
		||||
                                                     approve_nickname,
 | 
			
		||||
                                                     approve_domain,
 | 
			
		||||
                                                     approve_port,
 | 
			
		||||
| 
						 | 
				
			
			@ -281,8 +306,9 @@ def manual_approve_follow_request(session, base_dir: str,
 | 
			
		|||
                  approve_follows_filename + '.new')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def manual_approve_follow_request_thread(session, base_dir: str,
 | 
			
		||||
                                         http_prefix: str,
 | 
			
		||||
def manual_approve_follow_request_thread(session, session_onion, session_i2p,
 | 
			
		||||
                                         onion_domain: str, i2p_domain: str,
 | 
			
		||||
                                         base_dir: str, http_prefix: str,
 | 
			
		||||
                                         nickname: str, domain: str, port: int,
 | 
			
		||||
                                         approve_handle: str,
 | 
			
		||||
                                         federation_list: [],
 | 
			
		||||
| 
						 | 
				
			
			@ -297,8 +323,9 @@ def manual_approve_follow_request_thread(session, base_dir: str,
 | 
			
		|||
    """
 | 
			
		||||
    thr = \
 | 
			
		||||
        thread_with_trace(target=manual_approve_follow_request,
 | 
			
		||||
                          args=(session, base_dir,
 | 
			
		||||
                                http_prefix,
 | 
			
		||||
                          args=(session, session_onion, session_i2p,
 | 
			
		||||
                                onion_domain, i2p_domain,
 | 
			
		||||
                                base_dir, http_prefix,
 | 
			
		||||
                                nickname, domain, port,
 | 
			
		||||
                                approve_handle,
 | 
			
		||||
                                federation_list,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										15
									
								
								outbox.py
								
								
								
								
							
							
						
						
									
										15
									
								
								outbox.py
								
								
								
								
							| 
						 | 
				
			
			@ -9,7 +9,6 @@ __module_group__ = "Timeline"
 | 
			
		|||
 | 
			
		||||
import os
 | 
			
		||||
from shutil import copyfile
 | 
			
		||||
from session import create_session
 | 
			
		||||
from auth import create_password
 | 
			
		||||
from posts import is_image_media
 | 
			
		||||
from posts import outbox_message_create_wrap
 | 
			
		||||
| 
						 | 
				
			
			@ -489,12 +488,6 @@ def post_message_to_outbox(session, translate: {},
 | 
			
		|||
        if debug:
 | 
			
		||||
            print('DEBUG: Updated announcements (shares) collection ' +
 | 
			
		||||
                  'for the post associated with the Announce activity')
 | 
			
		||||
    if not server.session:
 | 
			
		||||
        print('DEBUG: creating new session for c2s')
 | 
			
		||||
        server.session = create_session(proxy_type)
 | 
			
		||||
        if not server.session:
 | 
			
		||||
            print('ERROR: Failed to create session for post_message_to_outbox')
 | 
			
		||||
            return False
 | 
			
		||||
    if debug:
 | 
			
		||||
        print('DEBUG: sending c2s post to followers')
 | 
			
		||||
    # remove inactive threads
 | 
			
		||||
| 
						 | 
				
			
			@ -517,6 +510,8 @@ def post_message_to_outbox(session, translate: {},
 | 
			
		|||
    # create a thread to send the post to followers
 | 
			
		||||
    followers_thread = \
 | 
			
		||||
        send_to_followers_thread(server.session,
 | 
			
		||||
                                 server.session_onion,
 | 
			
		||||
                                 server.session_i2p,
 | 
			
		||||
                                 base_dir,
 | 
			
		||||
                                 post_to_nickname,
 | 
			
		||||
                                 domain, onion_domain, i2p_domain,
 | 
			
		||||
| 
						 | 
				
			
			@ -658,8 +653,10 @@ def post_message_to_outbox(session, translate: {},
 | 
			
		|||
            print('c2s sender: ' +
 | 
			
		||||
                  post_to_nickname + '@' + domain + ':' + str(port))
 | 
			
		||||
    named_addresses_thread = \
 | 
			
		||||
        send_to_named_addresses_thread(server.session, base_dir,
 | 
			
		||||
                                       post_to_nickname,
 | 
			
		||||
        send_to_named_addresses_thread(server.session,
 | 
			
		||||
                                       server.session_onion,
 | 
			
		||||
                                       server.session_i2p,
 | 
			
		||||
                                       base_dir, post_to_nickname,
 | 
			
		||||
                                       domain, onion_domain, i2p_domain, port,
 | 
			
		||||
                                       http_prefix,
 | 
			
		||||
                                       federation_list,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										21
									
								
								person.py
								
								
								
								
							
							
						
						
									
										21
									
								
								person.py
								
								
								
								
							| 
						 | 
				
			
			@ -1427,10 +1427,10 @@ def _detect_users_path(url: str) -> str:
 | 
			
		|||
    return '/users/'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_actor_json(hostDomain: str, handle: str, http: bool, gnunet: bool,
 | 
			
		||||
def get_actor_json(host_domain: str, handle: str, http: bool, gnunet: bool,
 | 
			
		||||
                   debug: bool, quiet: bool,
 | 
			
		||||
                   signing_priv_key_pem: str,
 | 
			
		||||
                   existingSession) -> ({}, {}):
 | 
			
		||||
                   existing_session) -> ({}, {}):
 | 
			
		||||
    """Returns the actor json
 | 
			
		||||
    """
 | 
			
		||||
    if debug:
 | 
			
		||||
| 
						 | 
				
			
			@ -1513,10 +1513,16 @@ def get_actor_json(hostDomain: str, handle: str, http: bool, gnunet: bool,
 | 
			
		|||
            http_prefix = 'https'
 | 
			
		||||
        else:
 | 
			
		||||
            http_prefix = 'http'
 | 
			
		||||
    if existingSession:
 | 
			
		||||
        session = existingSession
 | 
			
		||||
    if existing_session:
 | 
			
		||||
        session = existing_session
 | 
			
		||||
        if debug:
 | 
			
		||||
            print('DEBUG: get_actor_json using existing session ' +
 | 
			
		||||
                  str(proxy_type) + ' ' + domain)
 | 
			
		||||
    else:
 | 
			
		||||
        session = create_session(proxy_type)
 | 
			
		||||
        if debug:
 | 
			
		||||
            print('DEBUG: get_actor_json using session ' +
 | 
			
		||||
                  str(proxy_type) + ' ' + domain)
 | 
			
		||||
    if nickname == 'inbox':
 | 
			
		||||
        nickname = domain
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1541,11 +1547,12 @@ def get_actor_json(hostDomain: str, handle: str, http: bool, gnunet: bool,
 | 
			
		|||
        handle = nickname + '@' + domain
 | 
			
		||||
        wf_request = webfinger_handle(session, handle,
 | 
			
		||||
                                      http_prefix, cached_webfingers,
 | 
			
		||||
                                      hostDomain, __version__, debug,
 | 
			
		||||
                                      host_domain, __version__, debug,
 | 
			
		||||
                                      group_account, signing_priv_key_pem)
 | 
			
		||||
        if not wf_request:
 | 
			
		||||
            if not quiet:
 | 
			
		||||
                print('get_actor_json Unable to webfinger ' + handle)
 | 
			
		||||
                print('get_actor_json Unable to webfinger ' + handle +
 | 
			
		||||
                      ' ' + http_prefix + ' proxy: ' + str(proxy_type))
 | 
			
		||||
            return None, None
 | 
			
		||||
        if not isinstance(wf_request, dict):
 | 
			
		||||
            if not quiet:
 | 
			
		||||
| 
						 | 
				
			
			@ -1600,7 +1607,7 @@ def get_actor_json(hostDomain: str, handle: str, http: bool, gnunet: bool,
 | 
			
		|||
        }
 | 
			
		||||
        person_json = \
 | 
			
		||||
            get_json(signing_priv_key_pem, session, person_url, as_header,
 | 
			
		||||
                     None, debug, __version__, http_prefix, hostDomain,
 | 
			
		||||
                     None, debug, __version__, http_prefix, host_domain,
 | 
			
		||||
                     20, quiet)
 | 
			
		||||
        if person_json:
 | 
			
		||||
            if not quiet:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										61
									
								
								posts.py
								
								
								
								
							
							
						
						
									
										61
									
								
								posts.py
								
								
								
								
							| 
						 | 
				
			
			@ -2981,7 +2981,8 @@ def _is_profile_update(post_json_object: {}) -> bool:
 | 
			
		|||
    return False
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def _send_to_named_addresses(session, base_dir: str,
 | 
			
		||||
def _send_to_named_addresses(session, session_onion, session_i2p,
 | 
			
		||||
                             base_dir: str,
 | 
			
		||||
                             nickname: str, domain: str,
 | 
			
		||||
                             onion_domain: str, i2p_domain: str, port: int,
 | 
			
		||||
                             http_prefix: str, federation_list: [],
 | 
			
		||||
| 
						 | 
				
			
			@ -3102,16 +3103,19 @@ def _send_to_named_addresses(session, base_dir: str,
 | 
			
		|||
        from_domain = domain
 | 
			
		||||
        from_domain_full = get_full_domain(domain, port)
 | 
			
		||||
        from_http_prefix = http_prefix
 | 
			
		||||
        curr_session = session
 | 
			
		||||
        if onion_domain:
 | 
			
		||||
            if to_domain.endswith('.onion'):
 | 
			
		||||
                from_domain = onion_domain
 | 
			
		||||
                from_domain_full = onion_domain
 | 
			
		||||
                from_http_prefix = 'http'
 | 
			
		||||
        elif i2p_domain:
 | 
			
		||||
                curr_session = session_onion
 | 
			
		||||
        if i2p_domain:
 | 
			
		||||
            if to_domain.endswith('.i2p'):
 | 
			
		||||
                from_domain = i2p_domain
 | 
			
		||||
                from_domain_full = i2p_domain
 | 
			
		||||
                from_http_prefix = 'http'
 | 
			
		||||
                curr_session = session_i2p
 | 
			
		||||
        cc_list = []
 | 
			
		||||
 | 
			
		||||
        # if the "to" domain is within the shared items
 | 
			
		||||
| 
						 | 
				
			
			@ -3125,7 +3129,7 @@ def _send_to_named_addresses(session, base_dir: str,
 | 
			
		|||
 | 
			
		||||
        group_account = has_group_type(base_dir, address, person_cache)
 | 
			
		||||
 | 
			
		||||
        send_signed_json(post_json_object, session, base_dir,
 | 
			
		||||
        send_signed_json(post_json_object, curr_session, base_dir,
 | 
			
		||||
                         nickname, from_domain, port,
 | 
			
		||||
                         to_nickname, to_domain, to_port,
 | 
			
		||||
                         cc_list, from_http_prefix, True, client_to_server,
 | 
			
		||||
| 
						 | 
				
			
			@ -3136,8 +3140,8 @@ def _send_to_named_addresses(session, base_dir: str,
 | 
			
		|||
                         signing_priv_key_pem, 34436782)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def send_to_named_addresses_thread(session, base_dir: str,
 | 
			
		||||
                                   nickname: str, domain: str,
 | 
			
		||||
def send_to_named_addresses_thread(session, session_onion, session_i2p,
 | 
			
		||||
                                   base_dir: str, nickname: str, domain: str,
 | 
			
		||||
                                   onion_domain: str,
 | 
			
		||||
                                   i2p_domain: str, port: int,
 | 
			
		||||
                                   http_prefix: str, federation_list: [],
 | 
			
		||||
| 
						 | 
				
			
			@ -3152,8 +3156,8 @@ def send_to_named_addresses_thread(session, base_dir: str,
 | 
			
		|||
    """
 | 
			
		||||
    send_thread = \
 | 
			
		||||
        thread_with_trace(target=_send_to_named_addresses,
 | 
			
		||||
                          args=(session, base_dir,
 | 
			
		||||
                                nickname, domain,
 | 
			
		||||
                          args=(session, session_onion, session_i2p,
 | 
			
		||||
                                base_dir, nickname, domain,
 | 
			
		||||
                                onion_domain, i2p_domain, port,
 | 
			
		||||
                                http_prefix, federation_list,
 | 
			
		||||
                                send_threads, post_log,
 | 
			
		||||
| 
						 | 
				
			
			@ -3209,9 +3213,8 @@ def _sending_profile_update(post_json_object: {}) -> bool:
 | 
			
		|||
    return False
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def send_to_followers(session, base_dir: str,
 | 
			
		||||
                      nickname: str,
 | 
			
		||||
                      domain: str,
 | 
			
		||||
def send_to_followers(session, session_onion, session_i2p,
 | 
			
		||||
                      base_dir: str, nickname: str, domain: str,
 | 
			
		||||
                      onion_domain: str, i2p_domain: str, port: int,
 | 
			
		||||
                      http_prefix: str, federation_list: [],
 | 
			
		||||
                      send_threads: [], post_log: [],
 | 
			
		||||
| 
						 | 
				
			
			@ -3224,9 +3227,6 @@ def send_to_followers(session, base_dir: str,
 | 
			
		|||
    """sends a post to the followers of the given nickname
 | 
			
		||||
    """
 | 
			
		||||
    print('send_to_followers')
 | 
			
		||||
    if not session:
 | 
			
		||||
        print('WARN: No session for send_to_followers')
 | 
			
		||||
        return
 | 
			
		||||
    if not _post_is_addressed_to_followers(base_dir, nickname, domain,
 | 
			
		||||
                                           port, http_prefix,
 | 
			
		||||
                                           post_json_object):
 | 
			
		||||
| 
						 | 
				
			
			@ -3278,9 +3278,25 @@ def send_to_followers(session, base_dir: str,
 | 
			
		|||
        print('Sending post to followers domain is active: ' +
 | 
			
		||||
              follower_domain_url)
 | 
			
		||||
 | 
			
		||||
        # select the appropriate session
 | 
			
		||||
        curr_session = session
 | 
			
		||||
        curr_http_prefix = http_prefix
 | 
			
		||||
        if onion_domain:
 | 
			
		||||
            if follower_domain.endswith('.onion'):
 | 
			
		||||
                curr_session = session_onion
 | 
			
		||||
                curr_http_prefix = 'http'
 | 
			
		||||
        if i2p_domain:
 | 
			
		||||
            if follower_domain.endswith('.i2p'):
 | 
			
		||||
                curr_session = session_i2p
 | 
			
		||||
                curr_http_prefix = 'http'
 | 
			
		||||
        if not curr_session:
 | 
			
		||||
            print('WARN: session not found when sending to follower ' +
 | 
			
		||||
                  follower_domain_url)
 | 
			
		||||
            continue
 | 
			
		||||
 | 
			
		||||
        with_shared_inbox = \
 | 
			
		||||
            _has_shared_inbox(session, http_prefix, follower_domain, debug,
 | 
			
		||||
                              signing_priv_key_pem)
 | 
			
		||||
            _has_shared_inbox(curr_session, curr_http_prefix, follower_domain,
 | 
			
		||||
                              debug, signing_priv_key_pem)
 | 
			
		||||
        if debug:
 | 
			
		||||
            if with_shared_inbox:
 | 
			
		||||
                print(follower_domain + ' has shared inbox')
 | 
			
		||||
| 
						 | 
				
			
			@ -3305,7 +3321,7 @@ def send_to_followers(session, base_dir: str,
 | 
			
		|||
            if to_domain.endswith('.onion'):
 | 
			
		||||
                from_domain = onion_domain
 | 
			
		||||
                from_http_prefix = 'http'
 | 
			
		||||
        elif i2p_domain:
 | 
			
		||||
        if i2p_domain:
 | 
			
		||||
            if to_domain.endswith('.i2p'):
 | 
			
		||||
                from_domain = i2p_domain
 | 
			
		||||
                from_http_prefix = 'http'
 | 
			
		||||
| 
						 | 
				
			
			@ -3333,7 +3349,7 @@ def send_to_followers(session, base_dir: str,
 | 
			
		|||
                  nickname + '@' + domain +
 | 
			
		||||
                  ' to ' + to_nickname + '@' + to_domain)
 | 
			
		||||
 | 
			
		||||
            send_signed_json(post_json_object, session, base_dir,
 | 
			
		||||
            send_signed_json(post_json_object, curr_session, base_dir,
 | 
			
		||||
                             nickname, from_domain, port,
 | 
			
		||||
                             to_nickname, to_domain, to_port,
 | 
			
		||||
                             cc_list, from_http_prefix, True,
 | 
			
		||||
| 
						 | 
				
			
			@ -3362,7 +3378,7 @@ def send_to_followers(session, base_dir: str,
 | 
			
		|||
                          nickname + '@' + domain + ' to ' +
 | 
			
		||||
                          to_nickname + '@' + to_domain)
 | 
			
		||||
 | 
			
		||||
                send_signed_json(post_json_object, session, base_dir,
 | 
			
		||||
                send_signed_json(post_json_object, curr_session, base_dir,
 | 
			
		||||
                                 nickname, from_domain, port,
 | 
			
		||||
                                 to_nickname, to_domain, to_port,
 | 
			
		||||
                                 cc_list, from_http_prefix, True,
 | 
			
		||||
| 
						 | 
				
			
			@ -3383,9 +3399,8 @@ def send_to_followers(session, base_dir: str,
 | 
			
		|||
    print('Sending post to followers ends ' + str(sending_mins) + ' mins')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def send_to_followers_thread(session, base_dir: str,
 | 
			
		||||
                             nickname: str,
 | 
			
		||||
                             domain: str,
 | 
			
		||||
def send_to_followers_thread(session, session_onion, session_i2p,
 | 
			
		||||
                             base_dir: str, nickname: str, domain: str,
 | 
			
		||||
                             onion_domain: str, i2p_domain: str, port: int,
 | 
			
		||||
                             http_prefix: str, federation_list: [],
 | 
			
		||||
                             send_threads: [], post_log: [],
 | 
			
		||||
| 
						 | 
				
			
			@ -3399,8 +3414,8 @@ def send_to_followers_thread(session, base_dir: str,
 | 
			
		|||
    """
 | 
			
		||||
    send_thread = \
 | 
			
		||||
        thread_with_trace(target=send_to_followers,
 | 
			
		||||
                          args=(session, base_dir,
 | 
			
		||||
                                nickname, domain,
 | 
			
		||||
                          args=(session, session_onion, session_i2p,
 | 
			
		||||
                                base_dir, nickname, domain,
 | 
			
		||||
                                onion_domain, i2p_domain, port,
 | 
			
		||||
                                http_prefix, federation_list,
 | 
			
		||||
                                send_threads, post_log,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										15
									
								
								schedule.py
								
								
								
								
							
							
						
						
									
										15
									
								
								schedule.py
								
								
								
								
							| 
						 | 
				
			
			@ -16,6 +16,7 @@ from utils import load_json
 | 
			
		|||
from utils import is_account_dir
 | 
			
		||||
from utils import acct_dir
 | 
			
		||||
from outbox import post_message_to_outbox
 | 
			
		||||
from session import create_session
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def _update_post_schedule(base_dir: str, handle: str, httpd,
 | 
			
		||||
| 
						 | 
				
			
			@ -93,7 +94,17 @@ def _update_post_schedule(base_dir: str, handle: str, httpd,
 | 
			
		|||
 | 
			
		||||
            if nickname:
 | 
			
		||||
                httpd.post_to_nickname = nickname
 | 
			
		||||
            if not post_message_to_outbox(httpd.session,
 | 
			
		||||
 | 
			
		||||
            # create session if needed
 | 
			
		||||
            curr_session = httpd.session
 | 
			
		||||
            curr_proxy_type = httpd.proxy_type
 | 
			
		||||
            if not curr_session:
 | 
			
		||||
                curr_session = create_session(httpd.proxy_type)
 | 
			
		||||
                httpd.session = curr_session
 | 
			
		||||
            if not curr_session:
 | 
			
		||||
                continue
 | 
			
		||||
 | 
			
		||||
            if not post_message_to_outbox(curr_session,
 | 
			
		||||
                                          httpd.translate,
 | 
			
		||||
                                          post_json_object, nickname,
 | 
			
		||||
                                          httpd, base_dir,
 | 
			
		||||
| 
						 | 
				
			
			@ -111,7 +122,7 @@ def _update_post_schedule(base_dir: str, handle: str, httpd,
 | 
			
		|||
                                          httpd.cached_webfingers,
 | 
			
		||||
                                          httpd.person_cache,
 | 
			
		||||
                                          httpd.allow_deletion,
 | 
			
		||||
                                          httpd.proxy_type,
 | 
			
		||||
                                          curr_proxy_type,
 | 
			
		||||
                                          httpd.project_version,
 | 
			
		||||
                                          httpd.debug,
 | 
			
		||||
                                          httpd.yt_replace_domain,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										45
									
								
								session.py
								
								
								
								
							
							
						
						
									
										45
									
								
								session.py
								
								
								
								
							| 
						 | 
				
			
			@ -767,3 +767,48 @@ def get_method(method_name: str, xml_str: str,
 | 
			
		|||
                print('EX: get_method failed, ' +
 | 
			
		||||
                      'connection was reset during get_vcard ' + str(ex))
 | 
			
		||||
    return None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_session_for_domains(server, calling_domain: str, referer_domain: str):
 | 
			
		||||
    """Returns the appropriate session for the given domains
 | 
			
		||||
    """
 | 
			
		||||
    if referer_domain is None:
 | 
			
		||||
        referer_domain = ''
 | 
			
		||||
 | 
			
		||||
    if '.onion:' in calling_domain or \
 | 
			
		||||
       calling_domain.endswith('.onion') or \
 | 
			
		||||
       '.onion:' in referer_domain or \
 | 
			
		||||
       referer_domain.endswith('.onion'):
 | 
			
		||||
        if not server.domain.endswith('.onion'):
 | 
			
		||||
            if server.onion_domain and server.session_onion:
 | 
			
		||||
                return server.session_onion, 'tor'
 | 
			
		||||
    if '.i2p:' in calling_domain or \
 | 
			
		||||
       calling_domain.endswith('.i2p') or \
 | 
			
		||||
       '.i2p:' in referer_domain or \
 | 
			
		||||
       referer_domain.endswith('.i2p'):
 | 
			
		||||
        if not server.domain.endswith('.i2p'):
 | 
			
		||||
            if server.i2p_domain and server.session_i2p:
 | 
			
		||||
                return server.session_i2p, 'i2p'
 | 
			
		||||
    return server.session, server.proxy_type
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_session_for_domain(server, referer_domain: str):
 | 
			
		||||
    """Returns the appropriate session for the given domain
 | 
			
		||||
    """
 | 
			
		||||
    return get_session_for_domains(server, referer_domain, referer_domain)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def set_session_for_sender(server, proxy_type: str, new_session) -> None:
 | 
			
		||||
    """Sets the appropriate session for the given sender
 | 
			
		||||
    """
 | 
			
		||||
    if proxy_type == 'tor':
 | 
			
		||||
        if not server.domain.endswith('.onion'):
 | 
			
		||||
            if server.onion_domain and server.session_onion:
 | 
			
		||||
                server.session_onion = new_session
 | 
			
		||||
                return
 | 
			
		||||
    if proxy_type == 'i2p':
 | 
			
		||||
        if not server.domain.endswith('.i2p'):
 | 
			
		||||
            if server.i2p_domain and server.session_i2p:
 | 
			
		||||
                server.session_i2p = new_session
 | 
			
		||||
                return
 | 
			
		||||
    server.session = new_session
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										12
									
								
								tests.py
								
								
								
								
							
							
						
						
									
										12
									
								
								tests.py
								
								
								
								
							| 
						 | 
				
			
			@ -1590,7 +1590,8 @@ def test_follow_between_servers(base_dir: str) -> None:
 | 
			
		|||
    signing_priv_key_pem = None
 | 
			
		||||
    send_result = \
 | 
			
		||||
        send_follow_request(session_alice, alice_dir,
 | 
			
		||||
                            'alice', alice_domain, alice_port, http_prefix,
 | 
			
		||||
                            'alice', alice_domain,
 | 
			
		||||
                            alice_domain, alice_port, http_prefix,
 | 
			
		||||
                            'bob', bob_domain, bob_actor,
 | 
			
		||||
                            bob_port, http_prefix,
 | 
			
		||||
                            client_to_server, federation_list,
 | 
			
		||||
| 
						 | 
				
			
			@ -1810,7 +1811,8 @@ def test_shared_items_federation(base_dir: str) -> None:
 | 
			
		|||
    bob_actor = http_prefix + '://' + bob_address + '/users/bob'
 | 
			
		||||
    send_result = \
 | 
			
		||||
        send_follow_request(session_alice, alice_dir,
 | 
			
		||||
                            'alice', alice_domain, alice_port, http_prefix,
 | 
			
		||||
                            'alice', alice_domain,
 | 
			
		||||
                            alice_domain, alice_port, http_prefix,
 | 
			
		||||
                            'bob', bob_domain, bob_actor,
 | 
			
		||||
                            bob_port, http_prefix,
 | 
			
		||||
                            client_to_server, federation_list,
 | 
			
		||||
| 
						 | 
				
			
			@ -2261,7 +2263,8 @@ def test_group_follow(base_dir: str) -> None:
 | 
			
		|||
    signing_priv_key_pem = None
 | 
			
		||||
    send_result = \
 | 
			
		||||
        send_follow_request(session_alice, alice_dir,
 | 
			
		||||
                            'alice', alice_domain, alice_port, http_prefix,
 | 
			
		||||
                            'alice', alice_domain,
 | 
			
		||||
                            alice_domain, alice_port, http_prefix,
 | 
			
		||||
                            'testgroup', testgroup_domain, testgroup_actor,
 | 
			
		||||
                            testgroupPort, http_prefix,
 | 
			
		||||
                            client_to_server, federation_list,
 | 
			
		||||
| 
						 | 
				
			
			@ -2338,7 +2341,8 @@ def test_group_follow(base_dir: str) -> None:
 | 
			
		|||
    signing_priv_key_pem = None
 | 
			
		||||
    send_result = \
 | 
			
		||||
        send_follow_request(session_bob, bob_dir,
 | 
			
		||||
                            'bob', bob_domain, bob_port, http_prefix,
 | 
			
		||||
                            'bob', bob_domain,
 | 
			
		||||
                            bob_domain, bob_port, http_prefix,
 | 
			
		||||
                            'testgroup', testgroup_domain, testgroup_actor,
 | 
			
		||||
                            testgroupPort, http_prefix,
 | 
			
		||||
                            client_to_server, federation_list,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										26
									
								
								utils.py
								
								
								
								
							
							
						
						
									
										26
									
								
								utils.py
								
								
								
								
							| 
						 | 
				
			
			@ -2023,6 +2023,32 @@ def is_public_post(post_json_object: {}) -> bool:
 | 
			
		|||
    return False
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def is_unlisted_post(post_json_object: {}) -> bool:
 | 
			
		||||
    """Returns true if the given post is unlisted
 | 
			
		||||
    """
 | 
			
		||||
    if not post_json_object.get('type'):
 | 
			
		||||
        return False
 | 
			
		||||
    if post_json_object['type'] != 'Create':
 | 
			
		||||
        return False
 | 
			
		||||
    if not has_object_dict(post_json_object):
 | 
			
		||||
        return False
 | 
			
		||||
    if not post_json_object['object'].get('to'):
 | 
			
		||||
        return False
 | 
			
		||||
    if not post_json_object['object'].get('cc'):
 | 
			
		||||
        return False
 | 
			
		||||
    has_followers = False
 | 
			
		||||
    for recipient in post_json_object['object']['to']:
 | 
			
		||||
        if recipient.endswith('/followers'):
 | 
			
		||||
            has_followers = True
 | 
			
		||||
            break
 | 
			
		||||
    if not has_followers:
 | 
			
		||||
        return False
 | 
			
		||||
    for recipient in post_json_object['object']['cc']:
 | 
			
		||||
        if recipient.endswith('#Public'):
 | 
			
		||||
            return True
 | 
			
		||||
    return False
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def copytree(src: str, dst: str, symlinks: str = False, ignore: bool = None):
 | 
			
		||||
    """Copy a directory
 | 
			
		||||
    """
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -122,12 +122,12 @@ def _html_new_post_drop_down(scope_icon: str, scope_description: str,
 | 
			
		|||
                'icons/scope_blog.png"/><b>' + \
 | 
			
		||||
                translate['Blog'] + '</b><br>' + \
 | 
			
		||||
                translate['Publicly visible post'] + '</a></li>\n'
 | 
			
		||||
        drop_down_content += \
 | 
			
		||||
            '<li><a href="' + path_base + dropdown_unlisted_suffix + \
 | 
			
		||||
            '"><img loading="lazy" alt="" title="" src="/' + \
 | 
			
		||||
            'icons/scope_unlisted.png"/><b>' + \
 | 
			
		||||
            translate['Unlisted'] + '</b><br>' + \
 | 
			
		||||
            translate['Not on public timeline'] + '</a></li>\n'
 | 
			
		||||
    drop_down_content += \
 | 
			
		||||
        '<li><a href="' + path_base + dropdown_unlisted_suffix + \
 | 
			
		||||
        '"><img loading="lazy" alt="" title="" src="/' + \
 | 
			
		||||
        'icons/scope_unlisted.png"/><b>' + \
 | 
			
		||||
        translate['Unlisted'] + '</b><br>' + \
 | 
			
		||||
        translate['Not on public timeline'] + '</a></li>\n'
 | 
			
		||||
    drop_down_content += \
 | 
			
		||||
        '<li><a href="' + path_base + dropdown_followers_suffix + \
 | 
			
		||||
        '" accesskey="' + access_keys['menuFollowers'] + '">' + \
 | 
			
		||||
| 
						 | 
				
			
			@ -300,8 +300,6 @@ def html_new_post(css_cache: {}, media_instance: bool, translate: {},
 | 
			
		|||
                        new_post_path = new_post_path.split('?')[0]
 | 
			
		||||
                    if new_post_path.endswith('/newpost'):
 | 
			
		||||
                        path = path.replace('/newpost', '/newfollowers')
 | 
			
		||||
                    elif new_post_path.endswith('/newunlisted'):
 | 
			
		||||
                        path = path.replace('/newunlisted', '/newfollowers')
 | 
			
		||||
                    show_public_on_dropdown = False
 | 
			
		||||
        else:
 | 
			
		||||
            new_post_text = \
 | 
			
		||||
| 
						 | 
				
			
			@ -694,7 +692,7 @@ def html_new_post(css_cache: {}, media_instance: bool, translate: {},
 | 
			
		|||
    if inReplyTo:
 | 
			
		||||
        dropdown_new_post_suffix += '?replyto=' + inReplyTo
 | 
			
		||||
        dropdown_new_blog_suffix += '?replyto=' + inReplyTo
 | 
			
		||||
        dropdown_unlisted_suffix += '?replyto=' + inReplyTo
 | 
			
		||||
        dropdown_unlisted_suffix += '?replyunlisted=' + inReplyTo
 | 
			
		||||
        dropdown_followers_suffix += '?replyfollowers=' + inReplyTo
 | 
			
		||||
        if reply_is_chat:
 | 
			
		||||
            dropdown_dm_suffix += '?replychat=' + inReplyTo
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -57,6 +57,7 @@ from utils import get_nickname_from_actor
 | 
			
		|||
from utils import get_domain_from_actor
 | 
			
		||||
from utils import acct_dir
 | 
			
		||||
from utils import local_actor_url
 | 
			
		||||
from utils import is_unlisted_post
 | 
			
		||||
from content import limit_repeated_words
 | 
			
		||||
from content import replace_emoji_from_tags
 | 
			
		||||
from content import html_replace_quote_marks
 | 
			
		||||
| 
						 | 
				
			
			@ -389,7 +390,7 @@ def _get_avatar_image_html(showAvatarOptions: bool,
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
def _get_reply_icon_html(base_dir: str, nickname: str, domain: str,
 | 
			
		||||
                         is_public_repeat: bool,
 | 
			
		||||
                         is_public_reply: bool, is_unlisted_reply: bool,
 | 
			
		||||
                         show_icons: bool, comments_enabled: bool,
 | 
			
		||||
                         post_json_object: {}, page_number_param: str,
 | 
			
		||||
                         translate: {}, system_language: str,
 | 
			
		||||
| 
						 | 
				
			
			@ -439,13 +440,20 @@ def _get_reply_icon_html(base_dir: str, nickname: str, domain: str,
 | 
			
		|||
    conversation_str = ''
 | 
			
		||||
    if conversation_id:
 | 
			
		||||
        conversation_str = '?conversationId=' + conversation_id
 | 
			
		||||
    if is_public_repeat:
 | 
			
		||||
    if is_public_reply:
 | 
			
		||||
        reply_str += \
 | 
			
		||||
            '        <a class="imageAnchor" href="/users/' + \
 | 
			
		||||
            nickname + '?replyto=' + reply_to_link + \
 | 
			
		||||
            '?actor=' + post_json_object['actor'] + \
 | 
			
		||||
            conversation_str + \
 | 
			
		||||
            '" title="' + reply_to_this_post_str + '">\n'
 | 
			
		||||
    elif is_unlisted_reply:
 | 
			
		||||
        reply_str += \
 | 
			
		||||
            '        <a class="imageAnchor" href="/users/' + \
 | 
			
		||||
            nickname + '?replyunlisted=' + reply_to_link + \
 | 
			
		||||
            '?actor=' + post_json_object['actor'] + \
 | 
			
		||||
            conversation_str + \
 | 
			
		||||
            '" title="' + reply_to_this_post_str + '">\n'
 | 
			
		||||
    else:
 | 
			
		||||
        if is_dm(post_json_object):
 | 
			
		||||
            reply_type = 'replydm'
 | 
			
		||||
| 
						 | 
				
			
			@ -1698,10 +1706,14 @@ def individual_post_as_html(signing_priv_key_pem: str,
 | 
			
		|||
            conversation_id = post_json_object['object']['conversation']
 | 
			
		||||
 | 
			
		||||
    public_reply = False
 | 
			
		||||
    unlisted_reply = False
 | 
			
		||||
    if is_public_post(post_json_object):
 | 
			
		||||
        public_reply = True
 | 
			
		||||
    if is_unlisted_post(post_json_object):
 | 
			
		||||
        public_reply = False
 | 
			
		||||
        unlisted_reply = True
 | 
			
		||||
    reply_str = _get_reply_icon_html(base_dir, nickname, domain,
 | 
			
		||||
                                     public_reply,
 | 
			
		||||
                                     public_reply, unlisted_reply,
 | 
			
		||||
                                     show_icons, comments_enabled,
 | 
			
		||||
                                     post_json_object, page_number_param,
 | 
			
		||||
                                     translate, system_language,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -144,7 +144,8 @@ def html_profile_after_search(css_cache: {},
 | 
			
		|||
                              max_like_count: int,
 | 
			
		||||
                              signing_priv_key_pem: str,
 | 
			
		||||
                              cw_lists: {}, lists_enabled: str,
 | 
			
		||||
                              timezone: str) -> str:
 | 
			
		||||
                              timezone: str,
 | 
			
		||||
                              onion_domain: str, i2p_domain: str) -> str:
 | 
			
		||||
    """Show a profile page after a search for a fediverse address
 | 
			
		||||
    """
 | 
			
		||||
    http = False
 | 
			
		||||
| 
						 | 
				
			
			@ -153,8 +154,17 @@ def html_profile_after_search(css_cache: {},
 | 
			
		|||
        http = True
 | 
			
		||||
    elif http_prefix == 'gnunet':
 | 
			
		||||
        gnunet = True
 | 
			
		||||
    from_domain = domain
 | 
			
		||||
    if onion_domain:
 | 
			
		||||
        if '.onion/' in profile_handle or profile_handle.endswith('.onion'):
 | 
			
		||||
            from_domain = onion_domain
 | 
			
		||||
            http = True
 | 
			
		||||
    if i2p_domain:
 | 
			
		||||
        if '.i2p/' in profile_handle or profile_handle.endswith('.i2p'):
 | 
			
		||||
            from_domain = i2p_domain
 | 
			
		||||
            http = True
 | 
			
		||||
    profile_json, as_header = \
 | 
			
		||||
        get_actor_json(domain, profile_handle, http, gnunet, debug, False,
 | 
			
		||||
        get_actor_json(from_domain, profile_handle, http, gnunet, debug, False,
 | 
			
		||||
                       signing_priv_key_pem, session)
 | 
			
		||||
    if not profile_json:
 | 
			
		||||
        return None
 | 
			
		||||
| 
						 | 
				
			
			@ -327,7 +337,7 @@ def html_profile_after_search(css_cache: {},
 | 
			
		|||
    user_feed = \
 | 
			
		||||
        parse_user_feed(signing_priv_key_pem,
 | 
			
		||||
                        session, outbox_url, as_header, project_version,
 | 
			
		||||
                        http_prefix, domain, debug)
 | 
			
		||||
                        http_prefix, from_domain, debug)
 | 
			
		||||
    if user_feed:
 | 
			
		||||
        i = 0
 | 
			
		||||
        for item in user_feed:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										20
									
								
								webfinger.py
								
								
								
								
							
							
						
						
									
										20
									
								
								webfinger.py
								
								
								
								
							| 
						 | 
				
			
			@ -68,12 +68,12 @@ def webfinger_handle(session, handle: str, http_prefix: str,
 | 
			
		|||
    """Gets webfinger result for the given ActivityPub handle
 | 
			
		||||
    """
 | 
			
		||||
    if not session:
 | 
			
		||||
        if debug:
 | 
			
		||||
            print('WARN: No session specified for webfinger_handle')
 | 
			
		||||
        print('WARN: No session specified for webfinger_handle')
 | 
			
		||||
        return None
 | 
			
		||||
 | 
			
		||||
    nickname, domain, _ = _parse_handle(handle)
 | 
			
		||||
    if not nickname:
 | 
			
		||||
        print('WARN: No nickname found in handle ' + handle)
 | 
			
		||||
        return None
 | 
			
		||||
    wf_domain = remove_domain_port(domain)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -123,14 +123,14 @@ def webfinger_handle(session, handle: str, http_prefix: str,
 | 
			
		|||
    if result:
 | 
			
		||||
        store_webfinger_in_cache(wf_handle, result, cached_webfingers)
 | 
			
		||||
    else:
 | 
			
		||||
        if debug:
 | 
			
		||||
            print("WARN: Unable to webfinger " + url + ' ' +
 | 
			
		||||
                  'nickname: ' + str(nickname) + ' ' +
 | 
			
		||||
                  'handle: ' + str(handle) + ' ' +
 | 
			
		||||
                  'wf_handle: ' + str(wf_handle) + ' ' +
 | 
			
		||||
                  'domain: ' + str(wf_domain) + ' ' +
 | 
			
		||||
                  'headers: ' + str(hdr) + ' ' +
 | 
			
		||||
                  'params: ' + str(par))
 | 
			
		||||
        print("WARN: Unable to webfinger " + url + ' ' +
 | 
			
		||||
              'from_domain: ' + from_domain + ' ' +
 | 
			
		||||
              'nickname: ' + str(nickname) + ' ' +
 | 
			
		||||
              'handle: ' + str(handle) + ' ' +
 | 
			
		||||
              'wf_handle: ' + str(wf_handle) + ' ' +
 | 
			
		||||
              'domain: ' + str(wf_domain) + ' ' +
 | 
			
		||||
              'headers: ' + str(hdr) + ' ' +
 | 
			
		||||
              'params: ' + str(par))
 | 
			
		||||
 | 
			
		||||
    return result
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue