mirror of https://gitlab.com/bashrc2/epicyon
Apply federated blocks when downloading announces
parent
2e23b3b9e5
commit
d296f166c5
|
@ -12959,6 +12959,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.debug,
|
self.server.debug,
|
||||||
self.server.buy_sites,
|
self.server.buy_sites,
|
||||||
self.server.blocked_cache,
|
self.server.blocked_cache,
|
||||||
|
self.server.block_federated,
|
||||||
self.server.auto_cw_cache)
|
self.server.auto_cw_cache)
|
||||||
if conv_str:
|
if conv_str:
|
||||||
msg = conv_str.encode('utf-8')
|
msg = conv_str.encode('utf-8')
|
||||||
|
|
|
@ -787,7 +787,8 @@ def _read_local_box_post(session, nickname: str, domain: str,
|
||||||
translate: {}, your_actor: str,
|
translate: {}, your_actor: str,
|
||||||
domain_full: str, person_cache: {},
|
domain_full: str, person_cache: {},
|
||||||
signing_priv_key_pem: str,
|
signing_priv_key_pem: str,
|
||||||
blocked_cache: {}, bold_reading: bool) -> {}:
|
blocked_cache: {}, block_federated: [],
|
||||||
|
bold_reading: bool) -> {}:
|
||||||
"""Reads a post from the given timeline
|
"""Reads a post from the given timeline
|
||||||
Returns the post json
|
Returns the post json
|
||||||
"""
|
"""
|
||||||
|
@ -835,7 +836,7 @@ def _read_local_box_post(session, nickname: str, domain: str,
|
||||||
system_language,
|
system_language,
|
||||||
domain_full, person_cache,
|
domain_full, person_cache,
|
||||||
signing_priv_key_pem,
|
signing_priv_key_pem,
|
||||||
blocked_cache, bold_reading,
|
blocked_cache, block_federated, bold_reading,
|
||||||
show_vote_posts,
|
show_vote_posts,
|
||||||
languages_understood)
|
languages_understood)
|
||||||
if post_json_object2:
|
if post_json_object2:
|
||||||
|
@ -1515,6 +1516,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
||||||
media_creator = ''
|
media_creator = ''
|
||||||
|
|
||||||
blocked_cache = {}
|
blocked_cache = {}
|
||||||
|
block_federated = []
|
||||||
languages_understood = []
|
languages_understood = []
|
||||||
|
|
||||||
indent = ' '
|
indent = ' '
|
||||||
|
@ -1811,7 +1813,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
||||||
espeak, translate, your_actor,
|
espeak, translate, your_actor,
|
||||||
domain_full, person_cache,
|
domain_full, person_cache,
|
||||||
signing_priv_key_pem,
|
signing_priv_key_pem,
|
||||||
blocked_cache, bold_reading)
|
blocked_cache, block_federated,
|
||||||
|
bold_reading)
|
||||||
print('')
|
print('')
|
||||||
say_str = 'Press Enter to continue...'
|
say_str = 'Press Enter to continue...'
|
||||||
say_str2 = _highlight_text(say_str)
|
say_str2 = _highlight_text(say_str)
|
||||||
|
@ -2685,6 +2688,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
||||||
domain_full, person_cache,
|
domain_full, person_cache,
|
||||||
signing_priv_key_pem,
|
signing_priv_key_pem,
|
||||||
blocked_cache,
|
blocked_cache,
|
||||||
|
block_federated,
|
||||||
bold_reading,
|
bold_reading,
|
||||||
show_vote_posts,
|
show_vote_posts,
|
||||||
languages_understood)
|
languages_understood)
|
||||||
|
|
|
@ -2720,9 +2720,11 @@ def _command_options() -> None:
|
||||||
signing_priv_key_pem = None
|
signing_priv_key_pem = None
|
||||||
if argb.secure_mode:
|
if argb.secure_mode:
|
||||||
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
|
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
|
||||||
|
block_federated = []
|
||||||
ctr = migrate_accounts(base_dir, session,
|
ctr = migrate_accounts(base_dir, session,
|
||||||
http_prefix, cached_webfingers,
|
http_prefix, cached_webfingers,
|
||||||
True, signing_priv_key_pem)
|
True, signing_priv_key_pem,
|
||||||
|
block_federated)
|
||||||
if ctr == 0:
|
if ctr == 0:
|
||||||
print('No followed accounts have moved')
|
print('No followed accounts have moved')
|
||||||
else:
|
else:
|
||||||
|
|
19
inbox.py
19
inbox.py
|
@ -729,7 +729,8 @@ def save_post_to_inbox_queue(base_dir: str, http_prefix: str,
|
||||||
print('No post Domain in actor')
|
print('No post Domain in actor')
|
||||||
return None
|
return None
|
||||||
if is_blocked(base_dir, nickname, domain,
|
if is_blocked(base_dir, nickname, domain,
|
||||||
post_nickname, post_domain, blocked_cache):
|
post_nickname, post_domain,
|
||||||
|
blocked_cache, block_federated):
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: post from ' + post_nickname + ' blocked')
|
print('DEBUG: post from ' + post_nickname + ' blocked')
|
||||||
return None
|
return None
|
||||||
|
@ -775,7 +776,7 @@ def save_post_to_inbox_queue(base_dir: str, http_prefix: str,
|
||||||
return None
|
return None
|
||||||
if is_blocked(base_dir, nickname, domain,
|
if is_blocked(base_dir, nickname, domain,
|
||||||
reply_nickname, reply_domain,
|
reply_nickname, reply_domain,
|
||||||
blocked_cache):
|
blocked_cache, block_federated):
|
||||||
if debug:
|
if debug:
|
||||||
print('WARN: post contains reply from ' +
|
print('WARN: post contains reply from ' +
|
||||||
str(actor) +
|
str(actor) +
|
||||||
|
@ -1833,6 +1834,7 @@ def _receive_move_activity(session, base_dir: str,
|
||||||
i2p_domain: str,
|
i2p_domain: str,
|
||||||
sites_unavailable: [],
|
sites_unavailable: [],
|
||||||
blocked_cache: [],
|
blocked_cache: [],
|
||||||
|
block_federated: [],
|
||||||
system_language: str) -> bool:
|
system_language: str) -> bool:
|
||||||
"""Receives a move activity within the POST section of HTTPServer
|
"""Receives a move activity within the POST section of HTTPServer
|
||||||
https://codeberg.org/fediverse/fep/src/branch/main/fep/7628/fep-7628.md
|
https://codeberg.org/fediverse/fep/src/branch/main/fep/7628/fep-7628.md
|
||||||
|
@ -1898,7 +1900,8 @@ def _receive_move_activity(session, base_dir: str,
|
||||||
return False
|
return False
|
||||||
# is the moved actor blocked?
|
# is the moved actor blocked?
|
||||||
if is_blocked(base_dir, nickname, domain,
|
if is_blocked(base_dir, nickname, domain,
|
||||||
moved_nickname, moved_domain, blocked_cache):
|
moved_nickname, moved_domain,
|
||||||
|
blocked_cache, block_federated):
|
||||||
print('INBOX: Move activity actor is blocked: ' + moved_actor)
|
print('INBOX: Move activity actor is blocked: ' + moved_actor)
|
||||||
return False
|
return False
|
||||||
print('INBOX: Move activity sending follow request: ' +
|
print('INBOX: Move activity sending follow request: ' +
|
||||||
|
@ -3208,7 +3211,8 @@ def _receive_announce(recent_posts_cache: {},
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: announced nickname is blocked')
|
print('DEBUG: announced nickname is blocked')
|
||||||
return False
|
return False
|
||||||
if is_blocked(base_dir, nickname, domain, actor_nickname, actor_domain):
|
if is_blocked(base_dir, nickname, domain, actor_nickname, actor_domain,
|
||||||
|
None, block_federated):
|
||||||
print('Receive announce blocked for actor: ' +
|
print('Receive announce blocked for actor: ' +
|
||||||
actor_nickname + '@' + actor_domain)
|
actor_nickname + '@' + actor_domain)
|
||||||
return False
|
return False
|
||||||
|
@ -3230,7 +3234,8 @@ def _receive_announce(recent_posts_cache: {},
|
||||||
print('WARN: _receive_announce no announced_actor_domain')
|
print('WARN: _receive_announce no announced_actor_domain')
|
||||||
return False
|
return False
|
||||||
if is_blocked(base_dir, nickname, domain,
|
if is_blocked(base_dir, nickname, domain,
|
||||||
announced_actor_nickname, announced_actor_domain):
|
announced_actor_nickname, announced_actor_domain,
|
||||||
|
None, block_federated):
|
||||||
print('Receive announce object blocked for actor: ' +
|
print('Receive announce object blocked for actor: ' +
|
||||||
announced_actor_nickname + '@' + announced_actor_domain)
|
announced_actor_nickname + '@' + announced_actor_domain)
|
||||||
return False
|
return False
|
||||||
|
@ -3324,7 +3329,8 @@ def _receive_announce(recent_posts_cache: {},
|
||||||
system_language,
|
system_language,
|
||||||
domain_full, person_cache,
|
domain_full, person_cache,
|
||||||
signing_priv_key_pem,
|
signing_priv_key_pem,
|
||||||
blocked_cache, bold_reading,
|
blocked_cache, block_federated,
|
||||||
|
bold_reading,
|
||||||
show_vote_posts,
|
show_vote_posts,
|
||||||
languages_understood)
|
languages_understood)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
|
@ -6467,6 +6473,7 @@ def run_inbox_queue(server,
|
||||||
i2p_domain,
|
i2p_domain,
|
||||||
server.sites_unavailable,
|
server.sites_unavailable,
|
||||||
server.blocked_cache,
|
server.blocked_cache,
|
||||||
|
server.block_federated,
|
||||||
server.system_language):
|
server.system_language):
|
||||||
if debug:
|
if debug:
|
||||||
print('Queue: _receive_move_activity ' + key_id)
|
print('Queue: _receive_move_activity ' + key_id)
|
||||||
|
|
18
migrate.py
18
migrate.py
|
@ -26,7 +26,8 @@ def _move_following_handles_for_account(base_dir: str,
|
||||||
http_prefix: str,
|
http_prefix: str,
|
||||||
cached_webfingers: {},
|
cached_webfingers: {},
|
||||||
debug: bool,
|
debug: bool,
|
||||||
signing_priv_key_pem: str) -> int:
|
signing_priv_key_pem: str,
|
||||||
|
block_federated: []) -> int:
|
||||||
"""Goes through all follows for an account and updates any that have moved
|
"""Goes through all follows for an account and updates any that have moved
|
||||||
"""
|
"""
|
||||||
ctr = 0
|
ctr = 0
|
||||||
|
@ -42,14 +43,16 @@ def _move_following_handles_for_account(base_dir: str,
|
||||||
_update_moved_handle(base_dir, nickname, domain,
|
_update_moved_handle(base_dir, nickname, domain,
|
||||||
follow_handle, session,
|
follow_handle, session,
|
||||||
http_prefix, cached_webfingers,
|
http_prefix, cached_webfingers,
|
||||||
debug, signing_priv_key_pem)
|
debug, signing_priv_key_pem,
|
||||||
|
block_federated)
|
||||||
return ctr
|
return ctr
|
||||||
|
|
||||||
|
|
||||||
def _update_moved_handle(base_dir: str, nickname: str, domain: str,
|
def _update_moved_handle(base_dir: str, nickname: str, domain: str,
|
||||||
handle: str, session,
|
handle: str, session,
|
||||||
http_prefix: str, cached_webfingers: {},
|
http_prefix: str, cached_webfingers: {},
|
||||||
debug: bool, signing_priv_key_pem: str) -> int:
|
debug: bool, signing_priv_key_pem: str,
|
||||||
|
block_federated: []) -> int:
|
||||||
"""Check if an account has moved, and if so then alter following.txt
|
"""Check if an account has moved, and if so then alter following.txt
|
||||||
for each account.
|
for each account.
|
||||||
Returns 1 if moved, 0 otherwise
|
Returns 1 if moved, 0 otherwise
|
||||||
|
@ -118,7 +121,8 @@ def _update_moved_handle(base_dir: str, nickname: str, domain: str,
|
||||||
moved_to_domain_full = moved_to_domain + ':' + str(moved_to_port)
|
moved_to_domain_full = moved_to_domain + ':' + str(moved_to_port)
|
||||||
group_account = has_group_type(base_dir, moved_to_url, None)
|
group_account = has_group_type(base_dir, moved_to_url, None)
|
||||||
if is_blocked(base_dir, nickname, domain,
|
if is_blocked(base_dir, nickname, domain,
|
||||||
moved_to_nickname, moved_to_domain):
|
moved_to_nickname, moved_to_domain,
|
||||||
|
None, block_federated):
|
||||||
# someone that you follow has moved to a blocked domain
|
# someone that you follow has moved to a blocked domain
|
||||||
# so just unfollow them
|
# so just unfollow them
|
||||||
unfollow_account(base_dir, nickname, domain,
|
unfollow_account(base_dir, nickname, domain,
|
||||||
|
@ -207,7 +211,8 @@ def _update_moved_handle(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
def migrate_accounts(base_dir: str, session,
|
def migrate_accounts(base_dir: str, session,
|
||||||
http_prefix: str, cached_webfingers: {},
|
http_prefix: str, cached_webfingers: {},
|
||||||
debug: bool, signing_priv_key_pem: str) -> int:
|
debug: bool, signing_priv_key_pem: str,
|
||||||
|
block_federated: []) -> int:
|
||||||
"""If followed accounts change then this modifies the
|
"""If followed accounts change then this modifies the
|
||||||
following lists for each account accordingly.
|
following lists for each account accordingly.
|
||||||
Returns the number of accounts migrated
|
Returns the number of accounts migrated
|
||||||
|
@ -224,6 +229,7 @@ def migrate_accounts(base_dir: str, session,
|
||||||
_move_following_handles_for_account(base_dir, nickname, domain,
|
_move_following_handles_for_account(base_dir, nickname, domain,
|
||||||
session, http_prefix,
|
session, http_prefix,
|
||||||
cached_webfingers, debug,
|
cached_webfingers, debug,
|
||||||
signing_priv_key_pem)
|
signing_priv_key_pem,
|
||||||
|
block_federated)
|
||||||
break
|
break
|
||||||
return ctr
|
return ctr
|
||||||
|
|
8
posts.py
8
posts.py
|
@ -4390,6 +4390,7 @@ def is_image_media(session, base_dir: str, http_prefix: str,
|
||||||
"""
|
"""
|
||||||
if post_json_object['type'] == 'Announce':
|
if post_json_object['type'] == 'Announce':
|
||||||
blocked_cache = {}
|
blocked_cache = {}
|
||||||
|
block_federated = []
|
||||||
post_json_announce = \
|
post_json_announce = \
|
||||||
download_announce(session, base_dir, http_prefix,
|
download_announce(session, base_dir, http_prefix,
|
||||||
nickname, domain, post_json_object,
|
nickname, domain, post_json_object,
|
||||||
|
@ -4401,7 +4402,8 @@ def is_image_media(session, base_dir: str, http_prefix: str,
|
||||||
system_language,
|
system_language,
|
||||||
domain_full, person_cache,
|
domain_full, person_cache,
|
||||||
signing_priv_key_pem,
|
signing_priv_key_pem,
|
||||||
blocked_cache, bold_reading,
|
blocked_cache, block_federated,
|
||||||
|
bold_reading,
|
||||||
show_vote_posts,
|
show_vote_posts,
|
||||||
languages_understood)
|
languages_understood)
|
||||||
if post_json_announce:
|
if post_json_announce:
|
||||||
|
@ -5784,7 +5786,8 @@ def download_announce(session, base_dir: str, http_prefix: str,
|
||||||
system_language: str,
|
system_language: str,
|
||||||
domain_full: str, person_cache: {},
|
domain_full: str, person_cache: {},
|
||||||
signing_priv_key_pem: str,
|
signing_priv_key_pem: str,
|
||||||
blocked_cache: {}, bold_reading: bool,
|
blocked_cache: {}, block_federated: [],
|
||||||
|
bold_reading: bool,
|
||||||
show_vote_posts: bool,
|
show_vote_posts: bool,
|
||||||
languages_understood: []) -> {}:
|
languages_understood: []) -> {}:
|
||||||
"""Download the post referenced by an announce
|
"""Download the post referenced by an announce
|
||||||
|
@ -5917,6 +5920,7 @@ def download_announce(session, base_dir: str, http_prefix: str,
|
||||||
convert_video_to_note(base_dir, nickname, domain,
|
convert_video_to_note(base_dir, nickname, domain,
|
||||||
system_language,
|
system_language,
|
||||||
announced_json, blocked_cache,
|
announced_json, blocked_cache,
|
||||||
|
block_federated,
|
||||||
languages_understood)
|
languages_understood)
|
||||||
if converted_json:
|
if converted_json:
|
||||||
announced_json = converted_json
|
announced_json = converted_json
|
||||||
|
|
|
@ -296,7 +296,7 @@ def _indicate_new_share_available(base_dir: str, http_prefix: str,
|
||||||
# does this account block you?
|
# does this account block you?
|
||||||
if account_nickname != nickname:
|
if account_nickname != nickname:
|
||||||
if is_blocked(base_dir, account_nickname, domain,
|
if is_blocked(base_dir, account_nickname, domain,
|
||||||
nickname, domain, None):
|
nickname, domain, None, None):
|
||||||
continue
|
continue
|
||||||
local_actor = \
|
local_actor = \
|
||||||
local_actor_url(http_prefix, account_nickname, domain_full)
|
local_actor_url(http_prefix, account_nickname, domain_full)
|
||||||
|
|
4
video.py
4
video.py
|
@ -26,6 +26,7 @@ from filters import is_filtered
|
||||||
def convert_video_to_note(base_dir: str, nickname: str, domain: str,
|
def convert_video_to_note(base_dir: str, nickname: str, domain: str,
|
||||||
system_language: str,
|
system_language: str,
|
||||||
post_json_object: {}, blocked_cache: {},
|
post_json_object: {}, blocked_cache: {},
|
||||||
|
block_federated: [],
|
||||||
languages_understood: []) -> {}:
|
languages_understood: []) -> {}:
|
||||||
"""Converts a PeerTube Video ActivityPub(ish) object into
|
"""Converts a PeerTube Video ActivityPub(ish) object into
|
||||||
a Note, so that it can then be displayed in a timeline
|
a Note, so that it can then be displayed in a timeline
|
||||||
|
@ -67,7 +68,8 @@ def convert_video_to_note(base_dir: str, nickname: str, domain: str,
|
||||||
return None
|
return None
|
||||||
post_domain_full = get_full_domain(post_domain, post_domain_port)
|
post_domain_full = get_full_domain(post_domain, post_domain_port)
|
||||||
if is_blocked(base_dir, nickname, domain,
|
if is_blocked(base_dir, nickname, domain,
|
||||||
post_nickname, post_domain_full, blocked_cache):
|
post_nickname, post_domain_full,
|
||||||
|
blocked_cache, block_federated):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# check that the content is valid
|
# check that the content is valid
|
||||||
|
|
|
@ -49,6 +49,7 @@ def html_conversation_view(authorized: bool, post_id: str,
|
||||||
min_images_for_accounts: [],
|
min_images_for_accounts: [],
|
||||||
debug: bool, buy_sites: {},
|
debug: bool, buy_sites: {},
|
||||||
blocked_cache: [],
|
blocked_cache: [],
|
||||||
|
block_federated: [],
|
||||||
auto_cw_cache: {}) -> str:
|
auto_cw_cache: {}) -> str:
|
||||||
"""Show a page containing a conversation thread
|
"""Show a page containing a conversation thread
|
||||||
"""
|
"""
|
||||||
|
@ -91,7 +92,7 @@ def html_conversation_view(authorized: bool, post_id: str,
|
||||||
if from_nickname and from_domain:
|
if from_nickname and from_domain:
|
||||||
if is_blocked(base_dir, nickname, domain,
|
if is_blocked(base_dir, nickname, domain,
|
||||||
from_nickname, from_domain,
|
from_nickname, from_domain,
|
||||||
blocked_cache):
|
blocked_cache, block_federated):
|
||||||
show_individual_post_icons = False
|
show_individual_post_icons = False
|
||||||
allow_deletion = False
|
allow_deletion = False
|
||||||
post_str = \
|
post_str = \
|
||||||
|
|
|
@ -2260,6 +2260,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
||||||
if post_json_object['type'] == 'Announce':
|
if post_json_object['type'] == 'Announce':
|
||||||
announce_json_object = post_json_object.copy()
|
announce_json_object = post_json_object.copy()
|
||||||
blocked_cache = {}
|
blocked_cache = {}
|
||||||
|
block_federated = []
|
||||||
show_vote_posts = True
|
show_vote_posts = True
|
||||||
show_vote_file = acct_dir(base_dir, nickname, domain) + '/.noVotes'
|
show_vote_file = acct_dir(base_dir, nickname, domain) + '/.noVotes'
|
||||||
if os.path.isfile(show_vote_file):
|
if os.path.isfile(show_vote_file):
|
||||||
|
@ -2275,7 +2276,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
||||||
system_language,
|
system_language,
|
||||||
domain_full, person_cache,
|
domain_full, person_cache,
|
||||||
signing_priv_key_pem,
|
signing_priv_key_pem,
|
||||||
blocked_cache, bold_reading,
|
blocked_cache, block_federated,
|
||||||
|
bold_reading,
|
||||||
show_vote_posts,
|
show_vote_posts,
|
||||||
languages_understood)
|
languages_understood)
|
||||||
if not post_json_announce:
|
if not post_json_announce:
|
||||||
|
|
|
@ -484,7 +484,7 @@ def shares_timeline_json(actor: str, page_number: int, items_per_page: int,
|
||||||
# Don't include shared items from blocked accounts
|
# Don't include shared items from blocked accounts
|
||||||
if account_nickname != nickname:
|
if account_nickname != nickname:
|
||||||
if is_blocked(base_dir, nickname, domain,
|
if is_blocked(base_dir, nickname, domain,
|
||||||
account_nickname, domain, None):
|
account_nickname, domain, None, None):
|
||||||
continue
|
continue
|
||||||
# actor who owns this share
|
# actor who owns this share
|
||||||
owner = actor.split('/users/')[0] + '/users/' + account_nickname
|
owner = actor.split('/users/')[0] + '/users/' + account_nickname
|
||||||
|
@ -529,7 +529,8 @@ def shares_timeline_json(actor: str, page_number: int, items_per_page: int,
|
||||||
if not share_nickname:
|
if not share_nickname:
|
||||||
continue
|
continue
|
||||||
if is_blocked(base_dir, nickname, domain,
|
if is_blocked(base_dir, nickname, domain,
|
||||||
share_nickname, federated_domain, None):
|
share_nickname, federated_domain,
|
||||||
|
None, None):
|
||||||
continue
|
continue
|
||||||
item['actor'] = share_actor
|
item['actor'] = share_actor
|
||||||
item['shareId'] = item_id
|
item['shareId'] = item_id
|
||||||
|
|
Loading…
Reference in New Issue