Premium accounts require follower approval

merge-requests/30/head
Bob Mottram 2024-03-20 20:54:03 +00:00
parent 0b4b366f84
commit 6614880043
3 changed files with 16 additions and 12 deletions

View File

@ -14,6 +14,7 @@ from socket import error as SocketError
from blocking import save_blocked_military
from httpheaders import redirect_headers
from httpheaders import clear_login_details
from utils import is_premium_account
from utils import remove_avatar_from_cache
from utils import is_memorial_account
from utils import save_json
@ -1231,7 +1232,8 @@ def _profile_post_reject_spam_actors(base_dir: str,
def _profile_post_approve_followers(on_final_welcome_screen: bool,
actor_json: {}, fields: {},
actor_changed: bool) -> bool:
actor_changed: bool,
premium: bool) -> bool:
""" HTTP POST approve followers
"""
if on_final_welcome_screen:
@ -1239,7 +1241,7 @@ def _profile_post_approve_followers(on_final_welcome_screen: bool,
actor_json['manuallyApprovesFollowers'] = True
actor_changed = True
else:
approve_followers = False
approve_followers = premium
if fields.get('approveFollowers'):
if fields['approveFollowers'] == 'on':
approve_followers = True
@ -2841,10 +2843,11 @@ def profile_edit(self, calling_domain: str, cookie: str,
if fields['removeScheduledPosts'] == 'on':
remove_scheduled_posts(base_dir, nickname, domain)
premium = is_premium_account(base_dir, nickname, domain)
actor_changed = \
_profile_post_approve_followers(on_final_welcome_screen,
actor_json, fields,
actor_changed)
actor_changed, premium)
_profile_post_reject_spam_actors(base_dir,
nickname, domain, fields)

View File

@ -5213,3 +5213,10 @@ def check_bad_path(path: str):
print('WARN: bad path ' + path)
return True
return False
def is_premium_account(base_dir: str, nickname: str, domain: str) -> bool:
""" Is the given account a premium one?
"""
premium_filename = acct_dir(base_dir, nickname, domain) + '/.premium'
return os.path.isfile(premium_filename)

View File

@ -10,6 +10,7 @@ __module_group__ = "Web Interface"
import os
from pprint import pprint
from webfinger import webfinger_handle
from utils import is_premium_account
from utils import time_days_ago
from utils import uninvert_text
from utils import get_attributed_to
@ -922,13 +923,6 @@ def _get_profile_header_after_search(base_dir: str,
return html_str
def _is_premium_account(base_dir: str, nickname: str, domain: str) -> bool:
""" Is the given account a premium one?
"""
premium_filename = acct_dir(base_dir, nickname, domain) + '/.premium'
return os.path.isfile(premium_filename)
def html_profile(signing_priv_key_pem: str,
rss_icon_at_top: bool,
icons_as_buttons: bool,
@ -1068,7 +1062,7 @@ def html_profile(signing_priv_key_pem: str,
briar_address = get_briar_address(profile_json)
cwtch_address = get_cwtch_address(profile_json)
verified_site_checkmark = ''
premium = _is_premium_account(base_dir, nickname, domain)
premium = is_premium_account(base_dir, nickname, domain)
if donate_url or website_url or repo_url or xmpp_address or \
matrix_address or ssb_address or tox_address or briar_address or \
cwtch_address or pgp_pub_key or enigma_pub_key or \
@ -2882,7 +2876,7 @@ def _html_edit_profile_main(base_dir: str, display_nickname: str, bio_str: str,
moved_to, 'https://...')
donate_str = translate['Donations link']
if _is_premium_account(base_dir, nickname, domain):
if is_premium_account(base_dir, nickname, domain):
donate_str = translate['Subscribe']
edit_profile_form += \
edit_text_field(donate_str, 'donateUrl', donate_url, 'https://...')