Option to now show follows on profile screen

merge-requests/30/head
Bob Mottram 2023-12-24 15:53:11 +00:00
parent 3a63bd54ad
commit 11e6a89f2f
31 changed files with 147 additions and 29 deletions

View File

@ -347,6 +347,7 @@ from utils import get_occupation_name
from utils import set_occupation_name
from utils import load_translations_from_file
from utils import load_bold_reading
from utils import load_hide_follows
from utils import get_local_network_addresses
from utils import decoded_host
from utils import is_public_post
@ -8051,6 +8052,33 @@ class PubServer(BaseHTTPRequestHandler):
'repliesFromMutualsOnly file ' +
show_replies_mutuals_file)
# hide follows checkbox
hide_follows_filename = \
acct_dir(base_dir, nickname, domain) + \
'/.bideFollows'
hide_follows = False
if fields.get('hideFollows'):
if fields['hideFollows'] == 'on':
hide_follows = True
self.server.hide_follows[nickname] = True
try:
with open(hide_follows_filename, 'w+',
encoding='utf-8') as rfile:
rfile.write('\n')
except OSError:
print('EX: unable to write hideFollows ' +
hide_follows_filename)
if not hide_follows:
if self.server.hide_follows.get(nickname):
del self.server.hide_follows[nickname]
if os.path.isfile(hide_follows_filename):
try:
os.remove(hide_follows_filename)
except OSError:
print('EX: _profile_edit ' +
'unable to delete ' +
hide_follows_filename)
# block military instances
block_mil_instances = False
if fields.get('blockMilitary'):
@ -15483,6 +15511,9 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
if not authorized and \
self.server.hide_follows.get(nickname):
following = {}
max_shares_on_profile = \
self.server.max_shares_on_profile
sites_unavailable = \
@ -15538,6 +15569,14 @@ class PubServer(BaseHTTPRequestHandler):
return True
else:
if self._secure_mode(curr_session, proxy_type):
if '/users/' in path:
nickname = path.split('/users/')[1]
if '/' in nickname:
nickname = nickname.split('/')[0]
if nickname and not authorized and \
self.server.hide_follows.get(nickname):
following = {}
msg_str = json.dumps(following,
ensure_ascii=False)
msg_str = self._convert_domains(calling_domain,
@ -15925,6 +15964,9 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
if not authorized and \
self.server.hide_follows.get(nickname):
followers = {}
max_shares_on_profile = \
self.server.max_shares_on_profile
sites_unavailable = \
@ -15981,6 +16023,14 @@ class PubServer(BaseHTTPRequestHandler):
return True
else:
if self._secure_mode(curr_session, proxy_type):
if '/users/' in path:
nickname = path.split('/users/')[1]
if '/' in nickname:
nickname = nickname.split('/')[0]
if nickname and not authorized and \
self.server.hide_follows.get(nickname):
followers = {}
msg_str = json.dumps(followers,
ensure_ascii=False)
msg_str = self._convert_domains(calling_domain,
@ -24183,6 +24233,9 @@ def run_daemon(public_replies_unlisted: int,
# for each account, whether bold reading is enabled
httpd.bold_reading = load_bold_reading(base_dir)
# whether to hide follows on profile screen for each account
httpd.hide_follows = load_hide_follows(base_dir)
httpd.account_timezone = load_account_timezones(base_dir)
httpd.post_to_nickname = None

View File

@ -521,6 +521,7 @@ def _create_person_base(base_dir: str, nickname: str, domain: str, port: int,
'discoverable': True,
'indexable': False,
'memorial': False,
'hideFollows': False,
'name': person_name,
'outbox': person_id + '/outbox',
'preferredUsername': person_name,
@ -850,6 +851,10 @@ def person_upgrade_actor(base_dir: str, person_json: {},
person_json['memorial'] = False
update_actor = True
if not person_json.get('hideFollows'):
person_json['hideFollows'] = False
update_actor = True
if not person_json.get('indexable'):
person_json['indexable'] = False
update_actor = True

View File

@ -641,5 +641,6 @@
"offline": "غير متصل على الانترنت",
"Mutuals": "التعاضد",
"Public replies default to unlisted scope": "الردود العامة افتراضية للنطاق غير المدرج",
"About the author": "عن المؤلف"
"About the author": "عن المؤلف",
"Do not show follows on your profile": "لا تظهر المتابعات في ملفك الشخصي"
}

View File

@ -641,5 +641,6 @@
"offline": "অফলাইন",
"Mutuals": "পারস্পরিক",
"Public replies default to unlisted scope": "অতালিকাভুক্ত সুযোগে সর্বজনীন উত্তর ডিফল্ট",
"About the author": "লেখক সম্পর্কে"
"About the author": "লেখক সম্পর্কে",
"Do not show follows on your profile": "আপনার প্রোফাইলে অনুসরণ দেখাবেন না"
}

View File

@ -641,5 +641,6 @@
"offline": "fora de línia",
"Mutuals": "Mútues",
"Public replies default to unlisted scope": "Les respostes públiques són per defecte a l'abast no llistat",
"About the author": "Sobre lautor"
"About the author": "Sobre lautor",
"Do not show follows on your profile": "No mostris els seguidors al teu perfil"
}

View File

@ -641,5 +641,6 @@
"offline": "all-lein",
"Mutuals": "Cydfuddiol",
"Public replies default to unlisted scope": "Ymatebion cyhoeddus rhagosodedig i gwmpas heb ei restru",
"About the author": "Am yr awdur"
"About the author": "Am yr awdur",
"Do not show follows on your profile": "Peidiwch â dangos dilyniannau ar eich proffil"
}

View File

@ -641,5 +641,6 @@
"offline": "offline",
"Mutuals": "Gegenseitigkeitsgesellschaften",
"Public replies default to unlisted scope": "Öffentliche Antworten werden standardmäßig auf den nicht aufgeführten Bereich übertragen",
"About the author": "Über den Autor"
"About the author": "Über den Autor",
"Do not show follows on your profile": "Zeigen Sie keine Follower in Ihrem Profil an"
}

View File

@ -641,5 +641,6 @@
"offline": "εκτός σύνδεσης",
"Mutuals": "Αμοιβαία",
"Public replies default to unlisted scope": "Οι δημόσιες απαντήσεις από προεπιλογή στο μη καταχωρισμένο εύρος",
"About the author": "Σχετικά με τον Συγγραφέα"
"About the author": "Σχετικά με τον Συγγραφέα",
"Do not show follows on your profile": "Μην εμφανίζονται οι ακόλουθοι στο προφίλ σας"
}

View File

@ -641,5 +641,6 @@
"offline": "offline",
"Mutuals": "Mutuals",
"Public replies default to unlisted scope": "Public replies default to unlisted scope",
"About the author": "About the author"
"About the author": "About the author",
"Do not show follows on your profile": "Do not show follows on your profile"
}

View File

@ -641,5 +641,6 @@
"offline": "desconectada",
"Mutuals": "Mutuales",
"Public replies default to unlisted scope": "Las respuestas públicas tienen por defecto un alcance no listado",
"About the author": "Sobre el Autor"
"About the author": "Sobre el Autor",
"Do not show follows on your profile": "No mostrar seguidores en tu perfil"
}

View File

@ -641,5 +641,6 @@
"offline": "آفلاین",
"Mutuals": "متقابل",
"Public replies default to unlisted scope": "پاسخ‌های عمومی به‌طور پیش‌فرض به محدوده فهرست نشده است",
"About the author": "درباره نویسنده"
"About the author": "درباره نویسنده",
"Do not show follows on your profile": "فالوورها را در نمایه خود نشان ندهید"
}

View File

@ -641,5 +641,6 @@
"offline": "hors ligne",
"Mutuals": "Mutuelles",
"Public replies default to unlisted scope": "Les réponses publiques ont par défaut une portée non répertoriée",
"About the author": "A propos de l'auteur"
"About the author": "A propos de l'auteur",
"Do not show follows on your profile": "Ne pas afficher les suivis sur votre profil"
}

View File

@ -641,5 +641,6 @@
"offline": "as líne",
"Mutuals": "Comhpháirteacha",
"Public replies default to unlisted scope": "Freagraí poiblí réamhshocraithe ar scóip neamhliostaithe",
"About the author": "Faoin tÚdar"
"About the author": "Faoin tÚdar",
"Do not show follows on your profile": "Ná taispeáin na nithe seo a leanas ar do phróifíl"
}

View File

@ -641,5 +641,6 @@
"offline": "במצב לא מקוון",
"Mutuals": "הדדיות",
"Public replies default to unlisted scope": "תשובות ציבוריות כברירת מחדל להיקף לא רשום",
"About the author": "על הסופר"
"About the author": "על הסופר",
"Do not show follows on your profile": "אל תראה עוקבים בפרופיל שלך"
}

View File

@ -641,5 +641,6 @@
"offline": "ऑफलाइन",
"Mutuals": "पारस्परिक",
"Public replies default to unlisted scope": "सार्वजनिक उत्तर डिफ़ॉल्ट रूप से असूचीबद्ध दायरे में आते हैं",
"About the author": "लेखक के बारे में"
"About the author": "लेखक के बारे में",
"Do not show follows on your profile": "अपनी प्रोफ़ाइल पर फ़ॉलो न दिखाएं"
}

View File

@ -641,5 +641,6 @@
"offline": "disconnessa",
"Mutuals": "Mutui",
"Public replies default to unlisted scope": "Per impostazione predefinita, le risposte pubbliche hanno un ambito non elencato",
"About the author": "Circa l'autore"
"About the author": "Circa l'autore",
"Do not show follows on your profile": "Non mostrare follower sul tuo profilo"
}

View File

@ -641,5 +641,6 @@
"offline": "オフライン",
"Mutuals": "相互作用",
"Public replies default to unlisted scope": "パブリック返信はデフォルトで非公開スコープになります",
"About the author": "著者について"
"About the author": "著者について",
"Do not show follows on your profile": "プロフィールにフォローを表示しない"
}

View File

@ -641,5 +641,6 @@
"offline": "오프라인",
"Mutuals": "상호",
"Public replies default to unlisted scope": "공개 답글은 기본적으로 비공개 범위로 설정됩니다.",
"About the author": "저자에 대해"
"About the author": "저자에 대해",
"Do not show follows on your profile": "프로필에 팔로우를 표시하지 않습니다."
}

View File

@ -641,5 +641,6 @@
"offline": "offline",
"Mutuals": "Mutuals",
"Public replies default to unlisted scope": "Bersivên gelemperî ji bo çarçoveyek nelîstekirî xwerû dide",
"About the author": "Di derbarê nivîskarê de"
"About the author": "Di derbarê nivîskarê de",
"Do not show follows on your profile": "Li ser profîla xwe şopandinê nîşan nedin"
}

View File

@ -641,5 +641,6 @@
"offline": "offline",
"Mutuals": "Mutualiteiten",
"Public replies default to unlisted scope": "Openbare antwoorden hebben standaard een niet-vermeld bereik",
"About the author": "Over de auteur"
"About the author": "Over de auteur",
"Do not show follows on your profile": "Laat geen volgers zien op je profiel"
}

View File

@ -637,5 +637,6 @@
"offline": "offline",
"Mutuals": "Mutuals",
"Public replies default to unlisted scope": "Public replies default to unlisted scope",
"About the author": "About the author"
"About the author": "About the author",
"Do not show follows on your profile": "Do not show follows on your profile"
}

View File

@ -641,5 +641,6 @@
"offline": "nieaktywny",
"Mutuals": "Wzajemne relacje",
"Public replies default to unlisted scope": "Odpowiedzi publiczne domyślnie mają zakres niepubliczny",
"About the author": "O autorze"
"About the author": "O autorze",
"Do not show follows on your profile": "Nie pokazuj obserwujących w swoim profilu"
}

View File

@ -641,5 +641,6 @@
"offline": "desligada",
"Mutuals": "Mútuas",
"Public replies default to unlisted scope": "As respostas públicas são padronizadas para escopo não listado",
"About the author": "Sobre o autor"
"About the author": "Sobre o autor",
"Do not show follows on your profile": "Não mostre seguidores em seu perfil"
}

View File

@ -641,5 +641,6 @@
"offline": "не в сети",
"Mutuals": "Взаимные отношения",
"Public replies default to unlisted scope": "Публичные ответы по умолчанию имеют скрытую область действия.",
"About the author": "Об авторе"
"About the author": "Об авторе",
"Do not show follows on your profile": "Не показывать подписчиков в своем профиле"
}

View File

@ -641,5 +641,6 @@
"offline": "nje ya mtandao",
"Mutuals": "Kuheshimiana",
"Public replies default to unlisted scope": "Majibu ya umma kwa chaguomsingi kwa upeo ambao haujaorodheshwa",
"About the author": "Kuhusu mwandishi"
"About the author": "Kuhusu mwandishi",
"Do not show follows on your profile": "Usionyeshe wafuasi kwenye wasifu wako"
}

View File

@ -641,5 +641,6 @@
"offline": "çevrimdışı",
"Mutuals": "Karşılıklar",
"Public replies default to unlisted scope": "Genel yanıtlar varsayılan olarak liste dışı kapsama alınır",
"About the author": "Yazar hakkında"
"About the author": "Yazar hakkında",
"Do not show follows on your profile": "Takip edilenleri profilinizde gösterme"
}

View File

@ -641,5 +641,6 @@
"offline": "офлайн",
"Mutuals": "Мутуали",
"Public replies default to unlisted scope": "Загальнодоступні відповіді за умовчанням мають приватний обсяг",
"About the author": "Про автора"
"About the author": "Про автора",
"Do not show follows on your profile": "Не показувати підписки у вашому профілі"
}

View File

@ -641,5 +641,6 @@
"offline": "אָפפלינע",
"Mutuals": "קעגנצייַטיק",
"Public replies default to unlisted scope": "ציבור ענטפֿערס פעליקייַט צו אַנליסטעד פאַרנעם",
"About the author": "וועגן דעם מחבר"
"About the author": "וועגן דעם מחבר",
"Do not show follows on your profile": "דו זאלסט נישט ווייַזן די פאלגענדע אויף דיין פּראָפיל"
}

View File

@ -641,5 +641,6 @@
"offline": "离线",
"Mutuals": "互助基金",
"Public replies default to unlisted scope": "公开回复默认为不公开范围",
"About the author": "关于作者"
"About the author": "关于作者",
"Do not show follows on your profile": "不要在您的个人资料上显示关注者"
}

View File

@ -4173,6 +4173,25 @@ def load_bold_reading(base_dir: str) -> {}:
return bold_reading
def load_hide_follows(base_dir: str) -> {}:
"""Returns a dictionary containing the hide follows status for each account
"""
hide_follows = {}
for _, dirs, _ in os.walk(base_dir + '/accounts'):
for acct in dirs:
if '@' not in acct:
continue
if acct.startswith('inbox@') or acct.startswith('Actor@'):
continue
hide_follows_filename = \
base_dir + '/accounts/' + acct + '/.hideFollows'
if os.path.isfile(hide_follows_filename):
nickname = acct.split('@')[0]
hide_follows[nickname] = True
break
return hide_follows
def get_account_timezone(base_dir: str, nickname: str, domain: str) -> str:
"""Returns the timezone for the given account
"""

View File

@ -1632,6 +1632,11 @@ def _html_profile_following(translate: {}, base_dir: str, http_prefix: str,
translate['Page up'] + '"></a>\n' + \
' </center>\n'
if not following_json:
following_json = {
'orderedItems': []
}
for following_actor in following_json['orderedItems']:
# is this a dormant followed account?
dormant = False
@ -2623,7 +2628,8 @@ def _html_edit_profile_options(is_admin: bool,
reverse_sequence: [],
show_vote_posts: bool,
show_replies_followers: bool,
show_replies_mutuals: bool) -> str:
show_replies_mutuals: bool,
hide_follows: bool) -> str:
"""option checkboxes section of edit profile screen
"""
edit_profile_form = ' <div class="container">\n'
@ -2685,6 +2691,9 @@ def _html_edit_profile_options(is_admin: bool,
edit_profile_form += \
edit_check_box(show_replies_mutuals_str, 'repliesFromMutualsOnly',
show_replies_mutuals)
hide_follows_str = translate['Do not show follows on your profile']
edit_profile_form += \
edit_check_box(hide_follows_str, 'hideFollows', hide_follows)
edit_profile_form += ' </div>\n'
return edit_profile_form
@ -3070,6 +3079,11 @@ def html_edit_profile(server, translate: {},
if os.path.isfile(account_dir + '/.repliesFromMutualsOnly'):
show_replies_mutuals = True
# don't show follows on profile
hide_follows = False
if os.path.isfile(account_dir + '/.hideFollows'):
hide_follows = True
# Option checkboxes
edit_profile_form += \
_html_edit_profile_options(is_admin, manually_approves_followers,
@ -3082,7 +3096,7 @@ def html_edit_profile(server, translate: {},
nickname, min_images_for_accounts,
reverse_sequence, show_vote_posts,
show_replies_followers,
show_replies_mutuals)
show_replies_mutuals, hide_follows)
# Contact information
edit_profile_form += \