mirror of https://gitlab.com/bashrc2/epicyon
				
				
				
			Prepare for alternative value field within attachments
							parent
							
								
									5b02a22519
								
							
						
					
					
						commit
						7648c1f6df
					
				
							
								
								
									
										32
									
								
								briar.py
								
								
								
								
							
							
						
						
									
										32
									
								
								briar.py
								
								
								
								
							| 
						 | 
				
			
			@ -8,6 +8,9 @@ __status__ = "Production"
 | 
			
		|||
__module_group__ = "Profile Metadata"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from utils import get_attachment_property_value
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_briar_address(actor_json: {}) -> str:
 | 
			
		||||
    """Returns briar address for the given actor
 | 
			
		||||
    """
 | 
			
		||||
| 
						 | 
				
			
			@ -25,26 +28,29 @@ def get_briar_address(actor_json: {}) -> str:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value.get('type'):
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value.get('value'):
 | 
			
		||||
        prop_value_name, prop_value = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value:
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        property_value['value'] = property_value['value'].strip()
 | 
			
		||||
        if len(property_value['value']) < 50:
 | 
			
		||||
        property_value[prop_value_name] = prop_value.strip()
 | 
			
		||||
        if len(property_value[prop_value_name]) < 50:
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value['value'].startswith('briar://'):
 | 
			
		||||
        if not property_value[prop_value_name].startswith('briar://'):
 | 
			
		||||
            continue
 | 
			
		||||
        if property_value['value'].lower() != property_value['value']:
 | 
			
		||||
        if property_value[prop_value_name].lower() != \
 | 
			
		||||
           property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if '"' in property_value['value']:
 | 
			
		||||
        if '"' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if ' ' in property_value['value']:
 | 
			
		||||
        if ' ' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if ',' in property_value['value']:
 | 
			
		||||
        if ',' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if '.' in property_value['value']:
 | 
			
		||||
        if '.' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        return property_value['value']
 | 
			
		||||
        return property_value[prop_value_name]
 | 
			
		||||
    return ''
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -108,7 +114,11 @@ def set_briar_address(actor_json: {}, briar_address: str) -> None:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        property_value['value'] = briar_address
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        property_value[prop_value_name] = briar_address
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    new_briar_address = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										26
									
								
								cwtch.py
								
								
								
								
							
							
						
						
									
										26
									
								
								cwtch.py
								
								
								
								
							| 
						 | 
				
			
			@ -8,6 +8,7 @@ __status__ = "Production"
 | 
			
		|||
__module_group__ = "Profile Metadata"
 | 
			
		||||
 | 
			
		||||
import re
 | 
			
		||||
from utils import get_attachment_property_value
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_cwtch_address(actor_json: {}) -> str:
 | 
			
		||||
| 
						 | 
				
			
			@ -27,22 +28,25 @@ def get_cwtch_address(actor_json: {}) -> str:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value.get('type'):
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value.get('value'):
 | 
			
		||||
        prop_value_name, prop_value = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value:
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        property_value['value'] = property_value['value'].strip()
 | 
			
		||||
        if len(property_value['value']) < 2:
 | 
			
		||||
        property_value[prop_value_name] = \
 | 
			
		||||
            property_value[prop_value_name].strip()
 | 
			
		||||
        if len(property_value[prop_value_name]) < 2:
 | 
			
		||||
            continue
 | 
			
		||||
        if '"' in property_value['value']:
 | 
			
		||||
        if '"' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if ' ' in property_value['value']:
 | 
			
		||||
        if ' ' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if ',' in property_value['value']:
 | 
			
		||||
        if ',' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if '.' in property_value['value']:
 | 
			
		||||
        if '.' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        return property_value['value']
 | 
			
		||||
        return property_value[prop_value_name]
 | 
			
		||||
    return ''
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -96,7 +100,11 @@ def set_cwtch_address(actor_json: {}, cwtch_address: str) -> None:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        property_value['value'] = cwtch_address
 | 
			
		||||
        prop_value_name, prop_value = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        property_value[prop_value_name] = cwtch_address
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    new_cwtch_address = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										23
									
								
								donate.py
								
								
								
								
							
							
						
						
									
										23
									
								
								donate.py
								
								
								
								
							| 
						 | 
				
			
			@ -8,6 +8,9 @@ __status__ = "Production"
 | 
			
		|||
__module_group__ = "Profile Metadata"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from utils import get_attachment_property_value
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def _get_donation_types() -> []:
 | 
			
		||||
    return ('patreon', 'paypal', 'gofundme', 'liberapay',
 | 
			
		||||
            'kickstarter', 'indiegogo', 'crowdsupply',
 | 
			
		||||
| 
						 | 
				
			
			@ -36,13 +39,15 @@ def get_donation_url(actor_json: {}) -> str:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value.get('type'):
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value.get('value'):
 | 
			
		||||
        prop_value_name, prop_value = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value:
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        if '<a href="' not in property_value['value']:
 | 
			
		||||
        if '<a href="' not in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        donate_url = property_value['value'].split('<a href="')[1]
 | 
			
		||||
        donate_url = property_value[prop_value_name].split('<a href="')[1]
 | 
			
		||||
        if '"' in donate_url:
 | 
			
		||||
            return donate_url.split('"')[0]
 | 
			
		||||
    return ''
 | 
			
		||||
| 
						 | 
				
			
			@ -67,11 +72,13 @@ def get_website(actor_json: {}, translate: {}) -> str:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value.get('type'):
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value.get('value'):
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        return property_value['value']
 | 
			
		||||
        return property_value[prop_value_name]
 | 
			
		||||
    return ''
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -139,7 +146,11 @@ def set_donation_url(actor_json: {}, donate_url: str) -> None:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        property_value['value'] = donate_value
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        property_value[prop_value_name] = donate_value
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    new_donate = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										15
									
								
								enigma.py
								
								
								
								
							
							
						
						
									
										15
									
								
								enigma.py
								
								
								
								
							| 
						 | 
				
			
			@ -8,6 +8,9 @@ __status__ = "Production"
 | 
			
		|||
__module_group__ = "Profile Metadata"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from utils import get_attachment_property_value
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_enigma_pub_key(actor_json: {}) -> str:
 | 
			
		||||
    """Returns Enigma public key for the given actor
 | 
			
		||||
    """
 | 
			
		||||
| 
						 | 
				
			
			@ -25,11 +28,13 @@ def get_enigma_pub_key(actor_json: {}) -> str:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value.get('type'):
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value.get('value'):
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        return property_value['value']
 | 
			
		||||
        return property_value[prop_value_name]
 | 
			
		||||
    return ''
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -78,7 +83,11 @@ def set_enigma_pub_key(actor_json: {}, enigma_pub_key: str) -> None:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        property_value['value'] = enigma_pub_key
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        property_value[prop_value_name] = enigma_pub_key
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    new_enigma_pub_key = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										23
									
								
								matrix.py
								
								
								
								
							
							
						
						
									
										23
									
								
								matrix.py
								
								
								
								
							| 
						 | 
				
			
			@ -8,6 +8,9 @@ __status__ = "Production"
 | 
			
		|||
__module_group__ = "Profile Metadata"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from utils import get_attachment_property_value
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_matrix_address(actor_json: {}) -> str:
 | 
			
		||||
    """Returns matrix address for the given actor
 | 
			
		||||
    """
 | 
			
		||||
| 
						 | 
				
			
			@ -25,19 +28,21 @@ def get_matrix_address(actor_json: {}) -> str:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value.get('type'):
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value.get('value'):
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        if '@' not in property_value['value']:
 | 
			
		||||
        if '@' not in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value['value'].startswith('@'):
 | 
			
		||||
        if not property_value[prop_value_name].startswith('@'):
 | 
			
		||||
            continue
 | 
			
		||||
        if ':' not in property_value['value']:
 | 
			
		||||
        if ':' not in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if '"' in property_value['value']:
 | 
			
		||||
        if '"' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        return property_value['value']
 | 
			
		||||
        return property_value[prop_value_name]
 | 
			
		||||
    return ''
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -93,7 +98,11 @@ def set_matrix_address(actor_json: {}, matrix_address: str) -> None:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        property_value['value'] = matrix_address
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        property_value[prop_value_name] = matrix_address
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    new_matrix_address = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										15
									
								
								outbox.py
								
								
								
								
							
							
						
						
									
										15
									
								
								outbox.py
								
								
								
								
							| 
						 | 
				
			
			@ -15,6 +15,7 @@ from posts import outbox_message_create_wrap
 | 
			
		|||
from posts import save_post_to_box
 | 
			
		||||
from posts import send_to_followers_thread
 | 
			
		||||
from posts import send_to_named_addresses_thread
 | 
			
		||||
from utils import get_attachment_property_value
 | 
			
		||||
from utils import get_account_timezone
 | 
			
		||||
from utils import has_object_string_type
 | 
			
		||||
from utils import get_base_content_from_post
 | 
			
		||||
| 
						 | 
				
			
			@ -141,7 +142,9 @@ def _person_receive_update_outbox(recent_posts_cache: {},
 | 
			
		|||
                continue
 | 
			
		||||
            if not new_property_value.get('type'):
 | 
			
		||||
                continue
 | 
			
		||||
            if not new_property_value.get('value'):
 | 
			
		||||
            prop_value_name, _ = \
 | 
			
		||||
                get_attachment_property_value(new_property_value)
 | 
			
		||||
            if not prop_value_name:
 | 
			
		||||
                continue
 | 
			
		||||
            if new_property_value['type'] != 'PropertyValue':
 | 
			
		||||
                continue
 | 
			
		||||
| 
						 | 
				
			
			@ -161,10 +164,10 @@ def _person_receive_update_outbox(recent_posts_cache: {},
 | 
			
		|||
                        actor_json['attachment'][attach_idx]['schema:name']
 | 
			
		||||
                if attach_name != name_value:
 | 
			
		||||
                    continue
 | 
			
		||||
                if actor_json['attachment'][attach_idx]['value'] != \
 | 
			
		||||
                   new_property_value['value']:
 | 
			
		||||
                    actor_json['attachment'][attach_idx]['value'] = \
 | 
			
		||||
                        new_property_value['value']
 | 
			
		||||
                if actor_json['attachment'][attach_idx][prop_value_name] != \
 | 
			
		||||
                   new_property_value[prop_value_name]:
 | 
			
		||||
                    actor_json['attachment'][attach_idx][prop_value_name] = \
 | 
			
		||||
                        new_property_value[prop_value_name]
 | 
			
		||||
                    actor_changed = True
 | 
			
		||||
                found = True
 | 
			
		||||
                break
 | 
			
		||||
| 
						 | 
				
			
			@ -172,7 +175,7 @@ def _person_receive_update_outbox(recent_posts_cache: {},
 | 
			
		|||
                actor_json['attachment'].append({
 | 
			
		||||
                    "name": name_value,
 | 
			
		||||
                    "type": "PropertyValue",
 | 
			
		||||
                    "value": new_property_value['value']
 | 
			
		||||
                    "value": new_property_value[prop_value_name]
 | 
			
		||||
                })
 | 
			
		||||
                actor_changed = True
 | 
			
		||||
    # save actor to file
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										35
									
								
								pgp.py
								
								
								
								
							
							
						
						
									
										35
									
								
								pgp.py
								
								
								
								
							| 
						 | 
				
			
			@ -30,6 +30,9 @@ from cwtch import get_cwtch_address
 | 
			
		|||
from blog import get_blog_address
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from utils import get_attachment_property_value
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_email_address(actor_json: {}) -> str:
 | 
			
		||||
    """Returns the email address for the given actor
 | 
			
		||||
    """
 | 
			
		||||
| 
						 | 
				
			
			@ -47,15 +50,17 @@ def get_email_address(actor_json: {}) -> str:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value.get('type'):
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value.get('value'):
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        if '@' not in property_value['value']:
 | 
			
		||||
        if '@' not in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if '.' not in property_value['value']:
 | 
			
		||||
        if '.' not in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        return property_value['value']
 | 
			
		||||
        return property_value[prop_value_name]
 | 
			
		||||
    return ''
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -76,13 +81,15 @@ def get_pgp_pub_key(actor_json: {}) -> str:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value.get('type'):
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value.get('value'):
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        if not contains_pgp_public_key(property_value['value']):
 | 
			
		||||
        if not contains_pgp_public_key(property_value[prop_value_name]):
 | 
			
		||||
            continue
 | 
			
		||||
        return property_value['value']
 | 
			
		||||
        return property_value[prop_value_name]
 | 
			
		||||
    return ''
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -103,13 +110,15 @@ def get_pgp_fingerprint(actor_json: {}) -> str:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value.get('type'):
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value.get('value'):
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        if len(property_value['value']) < 10:
 | 
			
		||||
        if len(property_value[prop_value_name]) < 10:
 | 
			
		||||
            continue
 | 
			
		||||
        return property_value['value']
 | 
			
		||||
        return property_value[prop_value_name]
 | 
			
		||||
    return ''
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -164,7 +173,11 @@ def set_email_address(actor_json: {}, email_address: str) -> None:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        property_value['value'] = email_address
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        property_value[prop_value_name] = email_address
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    new_email_address = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										28
									
								
								ssb.py
								
								
								
								
							
							
						
						
									
										28
									
								
								ssb.py
								
								
								
								
							| 
						 | 
				
			
			@ -8,6 +8,9 @@ __status__ = "Production"
 | 
			
		|||
__module_group__ = "Profile Metadata"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from utils import get_attachment_property_value
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_ssb_address(actor_json: {}) -> str:
 | 
			
		||||
    """Returns ssb address for the given actor
 | 
			
		||||
    """
 | 
			
		||||
| 
						 | 
				
			
			@ -25,22 +28,25 @@ def get_ssb_address(actor_json: {}) -> str:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value.get('type'):
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value.get('value'):
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        property_value['value'] = property_value['value'].strip()
 | 
			
		||||
        if not property_value['value'].startswith('@'):
 | 
			
		||||
        property_value[prop_value_name] = \
 | 
			
		||||
            property_value[prop_value_name].strip()
 | 
			
		||||
        if not property_value[prop_value_name].startswith('@'):
 | 
			
		||||
            continue
 | 
			
		||||
        if '=.' not in property_value['value']:
 | 
			
		||||
        if '=.' not in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if '"' in property_value['value']:
 | 
			
		||||
        if '"' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if ' ' in property_value['value']:
 | 
			
		||||
        if ' ' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if ',' in property_value['value']:
 | 
			
		||||
        if ',' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        return property_value['value']
 | 
			
		||||
        return property_value[prop_value_name]
 | 
			
		||||
    return ''
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -99,7 +105,11 @@ def set_ssb_address(actor_json: {}, ssb_address: str) -> None:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        property_value['value'] = ssb_address
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        property_value[prop_value_name] = ssb_address
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    new_ssb_address = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										31
									
								
								tox.py
								
								
								
								
							
							
						
						
									
										31
									
								
								tox.py
								
								
								
								
							| 
						 | 
				
			
			@ -8,6 +8,9 @@ __status__ = "Production"
 | 
			
		|||
__module_group__ = "Profile Metadata"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from utils import get_attachment_property_value
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_tox_address(actor_json: {}) -> str:
 | 
			
		||||
    """Returns tox address for the given actor
 | 
			
		||||
    """
 | 
			
		||||
| 
						 | 
				
			
			@ -25,24 +28,28 @@ def get_tox_address(actor_json: {}) -> str:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value.get('type'):
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value.get('value'):
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        property_value['value'] = property_value['value'].strip()
 | 
			
		||||
        if len(property_value['value']) != 76:
 | 
			
		||||
        property_value[prop_value_name] = \
 | 
			
		||||
            property_value[prop_value_name].strip()
 | 
			
		||||
        if len(property_value[prop_value_name]) != 76:
 | 
			
		||||
            continue
 | 
			
		||||
        if property_value['value'].upper() != property_value['value']:
 | 
			
		||||
        if property_value[prop_value_name].upper() != \
 | 
			
		||||
           property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if '"' in property_value['value']:
 | 
			
		||||
        if '"' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if ' ' in property_value['value']:
 | 
			
		||||
        if ' ' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if ',' in property_value['value']:
 | 
			
		||||
        if ',' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if '.' in property_value['value']:
 | 
			
		||||
        if '.' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        return property_value['value']
 | 
			
		||||
        return property_value[prop_value_name]
 | 
			
		||||
    return ''
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -104,7 +111,11 @@ def set_tox_address(actor_json: {}, tox_address: str) -> None:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        property_value['value'] = tox_address
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        property_value[prop_value_name] = tox_address
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    new_tox_address = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										45
									
								
								utils.py
								
								
								
								
							
							
						
						
									
										45
									
								
								utils.py
								
								
								
								
							| 
						 | 
				
			
			@ -63,16 +63,18 @@ def get_actor_languages_list(actor_json: {}) -> []:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value.get('type'):
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value.get('value'):
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        if isinstance(property_value['value'], list):
 | 
			
		||||
            lang_list = property_value['value']
 | 
			
		||||
        if isinstance(property_value[prop_value_name], list):
 | 
			
		||||
            lang_list = property_value[prop_value_name]
 | 
			
		||||
            lang_list.sort()
 | 
			
		||||
            return lang_list
 | 
			
		||||
        if isinstance(property_value['value'], str):
 | 
			
		||||
            lang_str = property_value['value']
 | 
			
		||||
        if isinstance(property_value[prop_value_name], str):
 | 
			
		||||
            lang_str = property_value[prop_value_name]
 | 
			
		||||
            lang_list_temp = []
 | 
			
		||||
            if ',' in lang_str:
 | 
			
		||||
                lang_list_temp = lang_str.split(',')
 | 
			
		||||
| 
						 | 
				
			
			@ -3129,26 +3131,28 @@ def get_actor_property_url(actor_json: {}, property_name: str) -> str:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value.get('type'):
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value.get('value'):
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        property_value['value'] = property_value['value'].strip()
 | 
			
		||||
        property_value['value'] = property_value[prop_value_name].strip()
 | 
			
		||||
        prefixes = get_protocol_prefixes()
 | 
			
		||||
        prefix_found = False
 | 
			
		||||
        for prefix in prefixes:
 | 
			
		||||
            if property_value['value'].startswith(prefix):
 | 
			
		||||
            if property_value[prop_value_name].startswith(prefix):
 | 
			
		||||
                prefix_found = True
 | 
			
		||||
                break
 | 
			
		||||
        if not prefix_found:
 | 
			
		||||
            continue
 | 
			
		||||
        if '.' not in property_value['value']:
 | 
			
		||||
        if '.' not in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if ' ' in property_value['value']:
 | 
			
		||||
        if ' ' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if ',' in property_value['value']:
 | 
			
		||||
        if ',' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        return property_value['value']
 | 
			
		||||
        return property_value[prop_value_name]
 | 
			
		||||
    return ''
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -3662,3 +3666,20 @@ def disallow_reply(content: str) -> bool:
 | 
			
		|||
        if diss in content:
 | 
			
		||||
            return True
 | 
			
		||||
    return False
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_attachment_property_value(property_value: {}) -> (str, str):
 | 
			
		||||
    """Returns the fieldname and value for an attachment property
 | 
			
		||||
    """
 | 
			
		||||
    prop_value = None
 | 
			
		||||
    prop_value_name = None
 | 
			
		||||
    if property_value.get('value'):
 | 
			
		||||
        prop_value = property_value['value']
 | 
			
		||||
        prop_value_name = 'value'
 | 
			
		||||
    elif property_value.get('http://schema.org#value'):
 | 
			
		||||
        prop_value = property_value['http://schema.org#value']
 | 
			
		||||
        prop_value_name = 'http://schema.org#value'
 | 
			
		||||
    elif property_value.get('https://schema.org#value'):
 | 
			
		||||
        prop_value = property_value['https://schema.org#value']
 | 
			
		||||
        prop_value_name = 'https://schema.org#value'
 | 
			
		||||
    return prop_value_name, prop_value
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,6 +11,7 @@ import os
 | 
			
		|||
from shutil import copyfile
 | 
			
		||||
from collections import OrderedDict
 | 
			
		||||
from session import get_json
 | 
			
		||||
from utils import get_attachment_property_value
 | 
			
		||||
from utils import is_account_dir
 | 
			
		||||
from utils import remove_html
 | 
			
		||||
from utils import get_protocol_prefixes
 | 
			
		||||
| 
						 | 
				
			
			@ -228,7 +229,11 @@ def _set_actor_property_url(actor_json: {},
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        property_value['value'] = url
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        property_value[prop_value_name] = url
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    new_address = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,6 +12,7 @@ import urllib.parse
 | 
			
		|||
from session import get_json
 | 
			
		||||
from cache import store_webfinger_in_cache
 | 
			
		||||
from cache import get_webfinger_from_cache
 | 
			
		||||
from utils import get_attachment_property_value
 | 
			
		||||
from utils import get_full_domain
 | 
			
		||||
from utils import load_json
 | 
			
		||||
from utils import load_json_onionify
 | 
			
		||||
| 
						 | 
				
			
			@ -433,12 +434,14 @@ def _webfinger_updateFromProfile(wf_json: {}, actor_json: {}) -> bool:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value.get('type'):
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value.get('value'):
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
 | 
			
		||||
        new_value = property_value['value'].strip()
 | 
			
		||||
        new_value = property_value[prop_value_name].strip()
 | 
			
		||||
        if '://' in new_value:
 | 
			
		||||
            new_value = new_value.split('://')[1]
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										19
									
								
								xmpp.py
								
								
								
								
							
							
						
						
									
										19
									
								
								xmpp.py
								
								
								
								
							| 
						 | 
				
			
			@ -8,6 +8,9 @@ __status__ = "Production"
 | 
			
		|||
__module_group__ = "Profile Metadata"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from utils import get_attachment_property_value
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_xmpp_address(actor_json: {}) -> str:
 | 
			
		||||
    """Returns xmpp address for the given actor
 | 
			
		||||
    """
 | 
			
		||||
| 
						 | 
				
			
			@ -26,15 +29,17 @@ def get_xmpp_address(actor_json: {}) -> str:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value.get('type'):
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value.get('value'):
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        if '@' not in property_value['value']:
 | 
			
		||||
        if '@' not in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        if '"' in property_value['value']:
 | 
			
		||||
        if '"' in property_value[prop_value_name]:
 | 
			
		||||
            continue
 | 
			
		||||
        return property_value['value']
 | 
			
		||||
        return property_value[prop_value_name]
 | 
			
		||||
    return ''
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -92,7 +97,11 @@ def set_xmpp_address(actor_json: {}, xmpp_address: str) -> None:
 | 
			
		|||
            continue
 | 
			
		||||
        if not property_value['type'].endswith('PropertyValue'):
 | 
			
		||||
            continue
 | 
			
		||||
        property_value['value'] = xmpp_address
 | 
			
		||||
        prop_value_name, _ = \
 | 
			
		||||
            get_attachment_property_value(property_value)
 | 
			
		||||
        if not prop_value_name:
 | 
			
		||||
            continue
 | 
			
		||||
        property_value[prop_value_name] = xmpp_address
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    new_xmpp_address = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue