mirror of https://gitlab.com/bashrc2/epicyon
Move local function
parent
a7f160064d
commit
fd7300b657
|
@ -36,7 +36,6 @@ from utils import get_instance_url
|
||||||
from utils import remove_html
|
from utils import remove_html
|
||||||
from utils import get_locked_account
|
from utils import get_locked_account
|
||||||
from utils import post_summary_contains_links
|
from utils import post_summary_contains_links
|
||||||
from utils import local_only_is_local
|
|
||||||
from utils import get_local_network_addresses
|
from utils import get_local_network_addresses
|
||||||
from utils import has_object_dict
|
from utils import has_object_dict
|
||||||
from utils import get_nickname_from_actor
|
from utils import get_nickname_from_actor
|
||||||
|
@ -44,6 +43,7 @@ from utils import get_domain_from_actor
|
||||||
from utils import get_actor_from_post
|
from utils import get_actor_from_post
|
||||||
from utils import has_actor
|
from utils import has_actor
|
||||||
from utils import resembles_url
|
from utils import resembles_url
|
||||||
|
from flags import local_only_is_local
|
||||||
from flags import is_system_account
|
from flags import is_system_account
|
||||||
from cache import check_for_changed_actor
|
from cache import check_for_changed_actor
|
||||||
from cache import get_person_from_cache
|
from cache import get_person_from_cache
|
||||||
|
|
39
flags.py
39
flags.py
|
@ -13,6 +13,8 @@ from timeFunctions import date_utcnow
|
||||||
from timeFunctions import get_published_date
|
from timeFunctions import get_published_date
|
||||||
from timeFunctions import date_from_string_format
|
from timeFunctions import date_from_string_format
|
||||||
from timeFunctions import date_epoch
|
from timeFunctions import date_epoch
|
||||||
|
from utils import get_full_domain
|
||||||
|
from utils import get_domain_from_actor
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
from utils import data_dir
|
from utils import data_dir
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
|
@ -680,3 +682,40 @@ def can_reply_to(base_dir: str, nickname: str, domain: str,
|
||||||
hours_since_publication >= reply_interval_hours:
|
hours_since_publication >= reply_interval_hours:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def local_only_is_local(message_json: {}, domain_full: str) -> bool:
|
||||||
|
"""Returns True if the given json post is verified as local only
|
||||||
|
"""
|
||||||
|
if message_json['object']['localOnly'] is not True:
|
||||||
|
return True
|
||||||
|
|
||||||
|
# check that the to addresses are local
|
||||||
|
if isinstance(message_json['object']['to'], list):
|
||||||
|
for to_actor in message_json['object']['to']:
|
||||||
|
to_domain, to_port = \
|
||||||
|
get_domain_from_actor(to_actor)
|
||||||
|
if not to_domain:
|
||||||
|
continue
|
||||||
|
to_domain_full = \
|
||||||
|
get_full_domain(to_domain, to_port)
|
||||||
|
if domain_full != to_domain_full:
|
||||||
|
print("REJECT: inbox " +
|
||||||
|
"local only post isn't local " +
|
||||||
|
str(message_json))
|
||||||
|
return False
|
||||||
|
|
||||||
|
# check that the sender is local
|
||||||
|
attrib_field = message_json['object']['attributedTo']
|
||||||
|
local_actor = get_attributed_to(attrib_field)
|
||||||
|
local_domain, local_port = \
|
||||||
|
get_domain_from_actor(local_actor)
|
||||||
|
if local_domain:
|
||||||
|
local_domain_full = \
|
||||||
|
get_full_domain(local_domain, local_port)
|
||||||
|
if domain_full != local_domain_full:
|
||||||
|
print("REJECT: " +
|
||||||
|
"inbox local only post isn't local " +
|
||||||
|
str(message_json))
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
37
utils.py
37
utils.py
|
@ -3842,43 +3842,6 @@ def resembles_url(text: str) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def local_only_is_local(message_json: {}, domain_full: str) -> bool:
|
|
||||||
"""Returns True if the given json post is verified as local only
|
|
||||||
"""
|
|
||||||
if message_json['object']['localOnly'] is not True:
|
|
||||||
return True
|
|
||||||
|
|
||||||
# check that the to addresses are local
|
|
||||||
if isinstance(message_json['object']['to'], list):
|
|
||||||
for to_actor in message_json['object']['to']:
|
|
||||||
to_domain, to_port = \
|
|
||||||
get_domain_from_actor(to_actor)
|
|
||||||
if not to_domain:
|
|
||||||
continue
|
|
||||||
to_domain_full = \
|
|
||||||
get_full_domain(to_domain, to_port)
|
|
||||||
if domain_full != to_domain_full:
|
|
||||||
print("REJECT: inbox " +
|
|
||||||
"local only post isn't local " +
|
|
||||||
str(message_json))
|
|
||||||
return False
|
|
||||||
|
|
||||||
# check that the sender is local
|
|
||||||
attrib_field = message_json['object']['attributedTo']
|
|
||||||
local_actor = get_attributed_to(attrib_field)
|
|
||||||
local_domain, local_port = \
|
|
||||||
get_domain_from_actor(local_actor)
|
|
||||||
if local_domain:
|
|
||||||
local_domain_full = \
|
|
||||||
get_full_domain(local_domain, local_port)
|
|
||||||
if domain_full != local_domain_full:
|
|
||||||
print("REJECT: " +
|
|
||||||
"inbox local only post isn't local " +
|
|
||||||
str(message_json))
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def post_summary_contains_links(message_json: {}) -> bool:
|
def post_summary_contains_links(message_json: {}) -> bool:
|
||||||
"""check if the json post summary contains links
|
"""check if the json post summary contains links
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue