mirror of https://gitlab.com/bashrc2/epicyon
Preparing for opt-in quote toots
parent
295983eea3
commit
d7e79c7761
15
inbox.py
15
inbox.py
|
@ -18,6 +18,7 @@ from languages import understood_post_language
|
|||
from like import update_likes_collection
|
||||
from reaction import update_reaction_collection
|
||||
from reaction import valid_emoji_content
|
||||
from utils import quote_toots_allowed
|
||||
from utils import get_post_attachments
|
||||
from utils import lines_in_file
|
||||
from utils import resembles_url
|
||||
|
@ -751,10 +752,16 @@ def save_post_to_inbox_queue(base_dir: str, http_prefix: str,
|
|||
|
||||
if obj_dict_exists:
|
||||
if is_quote_toot(post_json_object, content_str):
|
||||
if post_json_object.get('id'):
|
||||
print('REJECT: inbox quote toot ' +
|
||||
str(post_json_object['id']))
|
||||
return None
|
||||
allow_quotes = False
|
||||
if sending_actor:
|
||||
allow_quotes = \
|
||||
quote_toots_allowed(base_dir, nickname, domain,
|
||||
post_nickname, post_domain)
|
||||
if not allow_quotes:
|
||||
if post_json_object.get('id'):
|
||||
print('REJECT: inbox quote toot ' +
|
||||
str(post_json_object['id']))
|
||||
return None
|
||||
|
||||
# is this a reply to a blocked domain or account?
|
||||
reply_id = get_reply_to(post_json_object['object'])
|
||||
|
|
|
@ -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 quote_toots_allowed
|
||||
from utils import get_post_attachments
|
||||
from utils import get_attributed_to
|
||||
from utils import contains_invalid_actor_url_chars
|
||||
|
@ -311,8 +312,12 @@ def post_message_to_outbox(session, translate: {},
|
|||
return False
|
||||
|
||||
if is_quote_toot(message_json, ''):
|
||||
print('REJECT: POST quote toot ' + str(message_json))
|
||||
return False
|
||||
allow_quotes = \
|
||||
quote_toots_allowed(base_dir, post_to_nickname, domain,
|
||||
None, None)
|
||||
if not allow_quotes:
|
||||
print('REJECT: POST quote toot ' + str(message_json))
|
||||
return False
|
||||
|
||||
content_str = get_base_content_from_post(message_json, system_language)
|
||||
if content_str:
|
||||
|
|
21
utils.py
21
utils.py
|
@ -4801,6 +4801,27 @@ def is_quote_toot(post_json_object: str, content: str) -> bool:
|
|||
return False
|
||||
|
||||
|
||||
def quote_toots_allowed(base_dir: str, nickname: str, domain: str,
|
||||
sender_nickname: str, sender_domain: str) -> bool:
|
||||
""" Returns true if quote toots are allowed by the given account
|
||||
for the given sender
|
||||
"""
|
||||
account_dir = acct_dir(base_dir, nickname, domain)
|
||||
quotes_enabled_filename = account_dir + '/.allowQuotes'
|
||||
if os.path.isfile(quotes_enabled_filename):
|
||||
# check blocks on individual sending accounts
|
||||
quotes_blocked_filename = account_dir + '/quotesblocked.txt'
|
||||
if sender_nickname is None:
|
||||
return True
|
||||
if os.path.isfile(quotes_blocked_filename):
|
||||
sender_handle = sender_nickname + '@' + sender_domain
|
||||
if text_in_file(sender_handle, quotes_blocked_filename):
|
||||
# quote toots not permitted from this sender
|
||||
return False
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def license_link_from_name(license_name: str) -> str:
|
||||
"""Returns the license link from its name
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue