mirror of https://gitlab.com/bashrc2/epicyon
Option to not show boosts/announces of replies
parent
c4c167c0ed
commit
987181fa47
|
|
@ -805,6 +805,35 @@ def _profile_post_block_military(nickname: str, fields: {}, self) -> None:
|
||||||
self.server.block_military)
|
self.server.block_military)
|
||||||
|
|
||||||
|
|
||||||
|
def _profile_post_no_reply_boosts(base_dir: str, nickname: str, domain: str,
|
||||||
|
fields: {}) -> bool:
|
||||||
|
""" HTTP POST disallow boosts of replies in inbox
|
||||||
|
"""
|
||||||
|
no_reply_boosts_filename = \
|
||||||
|
acct_dir(base_dir, nickname, domain) + '/.noReplyBoosts'
|
||||||
|
no_reply_boosts = False
|
||||||
|
if fields.get('noReplyBoosts'):
|
||||||
|
if fields['noReplyBoosts'] == 'on':
|
||||||
|
no_reply_boosts = True
|
||||||
|
if no_reply_boosts:
|
||||||
|
if not os.path.isfile(no_reply_boosts_filename):
|
||||||
|
try:
|
||||||
|
with open(no_reply_boosts_filename, 'w+',
|
||||||
|
encoding='utf-8') as rfile:
|
||||||
|
rfile.write('\n')
|
||||||
|
except OSError:
|
||||||
|
print('EX: unable to write noReplyBoosts ' +
|
||||||
|
no_reply_boosts_filename)
|
||||||
|
if not no_reply_boosts:
|
||||||
|
if os.path.isfile(no_reply_boosts_filename):
|
||||||
|
try:
|
||||||
|
os.remove(no_reply_boosts_filename)
|
||||||
|
except OSError:
|
||||||
|
print('EX: _profile_edit ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
no_reply_boosts_filename)
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_hide_follows(base_dir: str, nickname: str, domain: str,
|
def _profile_post_hide_follows(base_dir: str, nickname: str, domain: str,
|
||||||
actor_json: {}, fields: {}, self,
|
actor_json: {}, fields: {}, self,
|
||||||
actor_changed: bool,
|
actor_changed: bool,
|
||||||
|
|
@ -2923,6 +2952,8 @@ def profile_edit(self, calling_domain: str, cookie: str,
|
||||||
actor_json, fields, self,
|
actor_json, fields, self,
|
||||||
actor_changed, premium)
|
actor_changed, premium)
|
||||||
_profile_post_block_military(nickname, fields, self)
|
_profile_post_block_military(nickname, fields, self)
|
||||||
|
_profile_post_no_reply_boosts(base_dir, nickname, domain,
|
||||||
|
fields)
|
||||||
|
|
||||||
notify_likes_filename = \
|
notify_likes_filename = \
|
||||||
acct_dir(base_dir, nickname, domain) + '/.notifyLikes'
|
acct_dir(base_dir, nickname, domain) + '/.notifyLikes'
|
||||||
|
|
|
||||||
19
inbox.py
19
inbox.py
|
|
@ -1585,6 +1585,7 @@ def _valid_post_content(base_dir: str, nickname: str, domain: str,
|
||||||
reply_id = get_reply_to(message_json['object'])
|
reply_id = get_reply_to(message_json['object'])
|
||||||
if reply_id:
|
if reply_id:
|
||||||
if isinstance(reply_id, str):
|
if isinstance(reply_id, str):
|
||||||
|
# this is a reply
|
||||||
original_post_id = reply_id
|
original_post_id = reply_id
|
||||||
post_post_filename = locate_post(base_dir, nickname, domain,
|
post_post_filename = locate_post(base_dir, nickname, domain,
|
||||||
original_post_id)
|
original_post_id)
|
||||||
|
|
@ -3372,8 +3373,23 @@ def _receive_announce(recent_posts_cache: {},
|
||||||
bold_reading,
|
bold_reading,
|
||||||
show_vote_posts,
|
show_vote_posts,
|
||||||
languages_understood)
|
languages_understood)
|
||||||
|
# are annouced/boosted replies allowed?
|
||||||
|
announce_denied = False
|
||||||
|
if post_json_object:
|
||||||
|
if has_object_dict(post_json_object):
|
||||||
|
if post_json_object['object'].get('inReplyTo'):
|
||||||
|
account_dir = acct_dir(base_dir, nickname, domain)
|
||||||
|
no_reply_boosts_filename = account_dir + '/.noReplyBoosts'
|
||||||
|
if os.path.isfile(no_reply_boosts_filename):
|
||||||
|
post_json_object = None
|
||||||
|
announce_denied = True
|
||||||
|
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
print('WARN: unable to download announce: ' + str(message_json))
|
if not announce_denied:
|
||||||
|
print('WARN: unable to download announce: ' + str(message_json))
|
||||||
|
else:
|
||||||
|
print('REJECT: Announce/Boost of reply denied ' +
|
||||||
|
message_json['object'])
|
||||||
not_in_onion = True
|
not_in_onion = True
|
||||||
if onion_domain:
|
if onion_domain:
|
||||||
if onion_domain in message_json['object']:
|
if onion_domain in message_json['object']:
|
||||||
|
|
@ -3391,6 +3407,7 @@ def _receive_announce(recent_posts_cache: {},
|
||||||
actor_url = get_actor_from_post(message_json)
|
actor_url = get_actor_from_post(message_json)
|
||||||
print('DEBUG: Announce post downloaded for ' +
|
print('DEBUG: Announce post downloaded for ' +
|
||||||
actor_url + ' -> ' + message_json['object'])
|
actor_url + ' -> ' + message_json['object'])
|
||||||
|
|
||||||
store_hash_tags(base_dir, nickname, domain,
|
store_hash_tags(base_dir, nickname, domain,
|
||||||
http_prefix, domain_full,
|
http_prefix, domain_full,
|
||||||
post_json_object, translate)
|
post_json_object, translate)
|
||||||
|
|
|
||||||
|
|
@ -2724,7 +2724,8 @@ def _html_edit_profile_options(is_admin: bool,
|
||||||
show_replies_followers: bool,
|
show_replies_followers: bool,
|
||||||
show_replies_mutuals: bool,
|
show_replies_mutuals: bool,
|
||||||
hide_follows: bool,
|
hide_follows: bool,
|
||||||
premium: bool) -> str:
|
premium: bool,
|
||||||
|
no_reply_boosts: bool) -> str:
|
||||||
"""option checkboxes section of edit profile screen
|
"""option checkboxes section of edit profile screen
|
||||||
"""
|
"""
|
||||||
edit_profile_form = ' <div class="container">\n'
|
edit_profile_form = ' <div class="container">\n'
|
||||||
|
|
@ -2764,9 +2765,11 @@ def _html_edit_profile_options(is_admin: bool,
|
||||||
edit_profile_form += \
|
edit_profile_form += \
|
||||||
edit_check_box(translate["Don't show the Reaction button"],
|
edit_check_box(translate["Don't show the Reaction button"],
|
||||||
'hideReactionButton', hide_reaction_button)
|
'hideReactionButton', hide_reaction_button)
|
||||||
|
|
||||||
bold_str = bold_reading_string(translate['Bold reading'])
|
bold_str = bold_reading_string(translate['Bold reading'])
|
||||||
edit_profile_form += \
|
edit_profile_form += \
|
||||||
edit_check_box(bold_str, 'boldReading', bold_reading)
|
edit_check_box(bold_str, 'boldReading', bold_reading)
|
||||||
|
|
||||||
minimize_all_images = False
|
minimize_all_images = False
|
||||||
if nickname in min_images_for_accounts:
|
if nickname in min_images_for_accounts:
|
||||||
minimize_all_images = True
|
minimize_all_images = True
|
||||||
|
|
@ -2774,31 +2777,40 @@ def _html_edit_profile_options(is_admin: bool,
|
||||||
edit_profile_form += \
|
edit_profile_form += \
|
||||||
edit_check_box(minimize_all_images_str, 'minimizeAllImages',
|
edit_check_box(minimize_all_images_str, 'minimizeAllImages',
|
||||||
minimize_all_images)
|
minimize_all_images)
|
||||||
|
|
||||||
reverse = False
|
reverse = False
|
||||||
if nickname in reverse_sequence:
|
if nickname in reverse_sequence:
|
||||||
reverse = True
|
reverse = True
|
||||||
reverse_str = translate['Reverse timelines']
|
reverse_str = translate['Reverse timelines']
|
||||||
edit_profile_form += \
|
edit_profile_form += \
|
||||||
edit_check_box(reverse_str, 'reverseTimelines', reverse)
|
edit_check_box(reverse_str, 'reverseTimelines', reverse)
|
||||||
|
|
||||||
show_vote_posts_str = translate['Show vote posts']
|
show_vote_posts_str = translate['Show vote posts']
|
||||||
edit_profile_form += \
|
edit_profile_form += \
|
||||||
edit_check_box(show_vote_posts_str, 'showVotes', show_vote_posts)
|
edit_check_box(show_vote_posts_str, 'showVotes', show_vote_posts)
|
||||||
|
|
||||||
show_replies_followers_str = translate['Only allow replies from followers']
|
show_replies_followers_str = translate['Only allow replies from followers']
|
||||||
if premium:
|
if premium:
|
||||||
show_replies_followers_str = translate['Only allow replies from fans']
|
show_replies_followers_str = translate['Only allow replies from fans']
|
||||||
edit_profile_form += \
|
edit_profile_form += \
|
||||||
edit_check_box(show_replies_followers_str, 'repliesFromFollowersOnly',
|
edit_check_box(show_replies_followers_str, 'repliesFromFollowersOnly',
|
||||||
show_replies_followers)
|
show_replies_followers)
|
||||||
|
|
||||||
show_replies_mutuals_str = translate['Only allow replies from mutuals']
|
show_replies_mutuals_str = translate['Only allow replies from mutuals']
|
||||||
edit_profile_form += \
|
edit_profile_form += \
|
||||||
edit_check_box(show_replies_mutuals_str, 'repliesFromMutualsOnly',
|
edit_check_box(show_replies_mutuals_str, 'repliesFromMutualsOnly',
|
||||||
show_replies_mutuals)
|
show_replies_mutuals)
|
||||||
|
|
||||||
hide_follows_str = translate['Do not show follows on your profile']
|
hide_follows_str = translate['Do not show follows on your profile']
|
||||||
if premium:
|
if premium:
|
||||||
hide_follows_str = translate['Do not show fans on your profile']
|
hide_follows_str = translate['Do not show fans on your profile']
|
||||||
edit_profile_form += \
|
edit_profile_form += \
|
||||||
edit_check_box(hide_follows_str, 'hideFollows', hide_follows)
|
edit_check_box(hide_follows_str, 'hideFollows', hide_follows)
|
||||||
|
|
||||||
|
no_reply_boosts_str = translate["Don't show boosted replies"]
|
||||||
|
edit_profile_form += \
|
||||||
|
edit_check_box(no_reply_boosts_str, 'noReplyBoosts', no_reply_boosts)
|
||||||
|
|
||||||
edit_profile_form += ' </div>\n'
|
edit_profile_form += ' </div>\n'
|
||||||
return edit_profile_form
|
return edit_profile_form
|
||||||
|
|
||||||
|
|
@ -3209,6 +3221,12 @@ def html_edit_profile(server, translate: {},
|
||||||
# is this a premium account?
|
# is this a premium account?
|
||||||
premium = is_premium_account(base_dir, nickname, domain)
|
premium = is_premium_account(base_dir, nickname, domain)
|
||||||
|
|
||||||
|
# are boosts of replies permitted in the inbox?
|
||||||
|
no_reply_boosts_filename = account_dir + '/.noReplyBoosts'
|
||||||
|
no_reply_boosts = False
|
||||||
|
if os.path.isfile(no_reply_boosts_filename):
|
||||||
|
no_reply_boosts = True
|
||||||
|
|
||||||
# Option checkboxes
|
# Option checkboxes
|
||||||
edit_profile_form += \
|
edit_profile_form += \
|
||||||
_html_edit_profile_options(is_admin, manually_approves_followers,
|
_html_edit_profile_options(is_admin, manually_approves_followers,
|
||||||
|
|
@ -3222,7 +3240,7 @@ def html_edit_profile(server, translate: {},
|
||||||
reverse_sequence, show_vote_posts,
|
reverse_sequence, show_vote_posts,
|
||||||
show_replies_followers,
|
show_replies_followers,
|
||||||
show_replies_mutuals, hide_follows,
|
show_replies_mutuals, hide_follows,
|
||||||
premium)
|
premium, no_reply_boosts)
|
||||||
|
|
||||||
# Contact information
|
# Contact information
|
||||||
edit_profile_form += \
|
edit_profile_form += \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue