Option to only allow replies from mutuals

merge-requests/30/head
Bob Mottram 2023-06-26 21:18:19 +01:00
parent 6f2dcc1aea
commit f8171509c1
29 changed files with 103 additions and 32 deletions

View File

@ -7678,6 +7678,34 @@ class PubServer(BaseHTTPRequestHandler):
'repliesFromFollowersOnly file ' +
show_replies_followers_file)
# show replies only from mutuals checkbox
show_replies_mutuals = False
if fields.get('repliesFromMutualsOnly'):
if fields['repliesFromMutualsOnly'] == 'on':
show_replies_mutuals = True
account_dir = acct_dir(self.server.base_dir,
nickname, self.server.domain)
show_replies_mutuals_file = \
account_dir + '/.repliesFromMutualsOnly'
if os.path.isfile(show_replies_mutuals_file):
if not show_replies_mutuals:
try:
os.remove(show_replies_mutuals_file)
except OSError:
print('EX: unable to remove ' +
'repliesFromMutualsOnly file ' +
show_replies_mutuals_file)
else:
if show_replies_mutuals:
try:
with open(show_replies_mutuals_file, 'w+',
encoding='utf-8') as fp_replies:
fp_replies.write('\n')
except OSError:
print('EX: unable to write ' +
'repliesFromMutualsOnly file ' +
show_replies_mutuals_file)
# notify about new Likes
if on_final_welcome_screen:
# default setting from welcome screen

View File

@ -624,9 +624,10 @@ def inbox_permitted_message(domain: str, message_json: {},
def _deny_non_follower(base_dir: str, nickname: str, domain: str,
reply_nickname: str, reply_domain: str,
sending_actor: str):
"""Returns true if replying to an account which is not a follower.
This only applies if 'Only replies from followers' is selected on
the edit profile screen
"""Returns true if replying to an account which is not a follower
or mutual.
This only applies if 'Only replies from followers' or
'Only replies from mutuals' is selected on the edit profile screen
"""
# Is this a reply to something written from this account?
if reply_nickname != nickname or reply_domain != domain:
@ -635,7 +636,8 @@ def _deny_non_follower(base_dir: str, nickname: str, domain: str,
# has this account specified to only receive replies from followers?
account_dir = acct_dir(base_dir, nickname, domain)
if not os.path.isfile(account_dir + '/.repliesFromFollowersOnly'):
return False
if not os.path.isfile(account_dir + '/.repliesFromMutualsOnly'):
return False
# is the sending actor a follower?
follower_nickname = get_nickname_from_actor(sending_actor)
@ -643,6 +645,10 @@ def _deny_non_follower(base_dir: str, nickname: str, domain: str,
if not is_follower_of_person(base_dir, nickname, domain,
follower_nickname, follower_domain):
return True
elif os.path.isfile(account_dir + '/.repliesFromMutualsOnly'):
if not is_following_actor(base_dir, nickname, domain,
sending_actor):
return True
return False

View File

@ -624,5 +624,6 @@
"Show vote posts": "إظهار مشاركات التصويت",
"Featured hashtags": "علامات التجزئة المميزة",
"Proxy": "الوكيل",
"Only allow replies from followers": "السماح فقط بالردود من المتابعين"
"Only allow replies from followers": "السماح فقط بالردود من المتابعين",
"Only allow replies from mutuals": "السماح فقط بالردود من المتبادلين"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "ভোট পোস্ট দেখান",
"Featured hashtags": "বৈশিষ্ট্যযুক্ত হ্যাশট্যাগ",
"Proxy": "প্রক্সি",
"Only allow replies from followers": "শুধুমাত্র অনুসরণকারীদের কাছ থেকে উত্তরের অনুমতি দিন"
"Only allow replies from followers": "শুধুমাত্র অনুসরণকারীদের কাছ থেকে উত্তরের অনুমতি দিন",
"Only allow replies from mutuals": "শুধুমাত্র মিউচুয়াল থেকে উত্তরের অনুমতি দিন"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "Mostra les publicacions de vot",
"Featured hashtags": "Hashtags destacats",
"Proxy": "Proxy",
"Only allow replies from followers": "Només permet respostes dels seguidors"
"Only allow replies from followers": "Només permet respostes dels seguidors",
"Only allow replies from mutuals": "Només permet respostes de mútues"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "Dangos postiadau pleidlais",
"Featured hashtags": "Hashtags dan sylw",
"Proxy": "Dirprwy",
"Only allow replies from followers": "Caniatewch atebion gan ddilynwyr yn unig"
"Only allow replies from followers": "Caniatewch atebion gan ddilynwyr yn unig",
"Only allow replies from mutuals": "Caniatewch atebion gan gwmnïau cydfuddiannol yn unig"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "Abstimmungsbeiträge anzeigen",
"Featured hashtags": "Ausgewählte Hashtags",
"Proxy": "Stellvertreterin",
"Only allow replies from followers": "Erlauben Sie nur Antworten von Followern"
"Only allow replies from followers": "Erlauben Sie nur Antworten von Followern",
"Only allow replies from mutuals": "Erlauben Sie nur Antworten von Gegenseitigkeitsgesellschaften"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "Εμφάνιση ψηφοφοριακών αναρτήσεων",
"Featured hashtags": "Επιλεγμένα hashtag",
"Proxy": "Πληρεξούσιο",
"Only allow replies from followers": "Επιτρέπονται μόνο οι απαντήσεις από τους ακόλουθους"
"Only allow replies from followers": "Επιτρέπονται μόνο οι απαντήσεις από τους ακόλουθους",
"Only allow replies from mutuals": "Επιτρέπονται μόνο απαντήσεις από αμοιβαία μέλη"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "Show vote posts",
"Featured hashtags": "Featured hashtags",
"Proxy": "Proxy",
"Only allow replies from followers": "Only allow replies from followers"
"Only allow replies from followers": "Only allow replies from followers",
"Only allow replies from mutuals": "Only allow replies from mutuals"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "Mostrar publicaciones de votos",
"Featured hashtags": "Hashtags destacados",
"Proxy": "Apoderada",
"Only allow replies from followers": "Permitir solo respuestas de seguidores"
"Only allow replies from followers": "Permitir solo respuestas de seguidores",
"Only allow replies from mutuals": "Permitir solo respuestas de mutuas"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "نمایش پست های رای",
"Featured hashtags": "هشتگ های ویژه",
"Proxy": "پروکسی",
"Only allow replies from followers": "فقط اجازه پاسخ از طرفداران را بدهید"
"Only allow replies from followers": "فقط اجازه پاسخ از طرفداران را بدهید",
"Only allow replies from mutuals": "فقط اجازه پاسخ از طرف متقابل را بدهید"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "Afficher les messages de vote",
"Featured hashtags": "Mots-clics en vedette",
"Proxy": "Procuration",
"Only allow replies from followers": "Autoriser uniquement les réponses des abonnés"
"Only allow replies from followers": "Autoriser uniquement les réponses des abonnés",
"Only allow replies from mutuals": "Autoriser uniquement les réponses des mutuelles"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "Taispeáin postálacha vótaí",
"Featured hashtags": "Hashtags faoi thrácht",
"Proxy": "Seachfhreastalaí",
"Only allow replies from followers": "Ná ceadaigh ach freagraí ó leantóirí"
"Only allow replies from followers": "Ná ceadaigh ach freagraí ó leantóirí",
"Only allow replies from mutuals": "Ná ceadaigh ach freagraí ó chomhlachtaí frithpháirteacha"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "वोट पोस्ट दिखाएं",
"Featured hashtags": "विशेष रुप से प्रदर्शित हैशटैग",
"Proxy": "प्रतिनिधि",
"Only allow replies from followers": "केवल अनुयायियों के उत्तरों की अनुमति दें"
"Only allow replies from followers": "केवल अनुयायियों के उत्तरों की अनुमति दें",
"Only allow replies from mutuals": "केवल पारस्परिक उत्तरों की अनुमति दें"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "Mostra messaggi di voto",
"Featured hashtags": "Hashtag in primo piano",
"Proxy": "Delega",
"Only allow replies from followers": "Consenti solo risposte dai follower"
"Only allow replies from followers": "Consenti solo risposte dai follower",
"Only allow replies from mutuals": "Consenti solo risposte da mutue"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "投票投稿を表示",
"Featured hashtags": "注目のハッシュタグ",
"Proxy": "プロキシー",
"Only allow replies from followers": "フォロワーからの返信のみを許可する"
"Only allow replies from followers": "フォロワーからの返信のみを許可する",
"Only allow replies from mutuals": "相互からの返信のみを許可する"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "투표 게시물 표시",
"Featured hashtags": "추천 해시태그",
"Proxy": "대리",
"Only allow replies from followers": "팔로어의 답글만 허용"
"Only allow replies from followers": "팔로어의 답글만 허용",
"Only allow replies from mutuals": "상호 간의 답장만 허용"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "Mesajên dengdanê nîşan bide",
"Featured hashtags": "Hashtagên taybetmendî",
"Proxy": "Proxy",
"Only allow replies from followers": "Tenê destûr bidin bersivên ji şagirtan"
"Only allow replies from followers": "Tenê destûr bidin bersivên ji şagirtan",
"Only allow replies from mutuals": "Tenê destûr bidin bersivên ji hevdu"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "Toon stemberichten",
"Featured hashtags": "Aanbevolen hashtags",
"Proxy": "Volmacht",
"Only allow replies from followers": "Sta alleen reacties van volgers toe"
"Only allow replies from followers": "Sta alleen reacties van volgers toe",
"Only allow replies from mutuals": "Sta alleen reacties van onderlinge maatschappijen toe"
}

View File

@ -620,5 +620,6 @@
"Show vote posts": "Show vote posts",
"Featured hashtags": "Featured hashtags",
"Proxy": "Proxy",
"Only allow replies from followers": "Only allow replies from followers"
"Only allow replies from followers": "Only allow replies from followers",
"Only allow replies from mutuals": "Only allow replies from mutuals"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "Pokaż posty z głosowaniem",
"Featured hashtags": "Polecane hashtagi",
"Proxy": "Pełnomocnik",
"Only allow replies from followers": "Zezwalaj tylko na odpowiedzi od obserwujących"
"Only allow replies from followers": "Zezwalaj tylko na odpowiedzi od obserwujących",
"Only allow replies from mutuals": "Zezwalaj tylko na odpowiedzi od towarzystw wzajemnych"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "Mostrar postagens de votação",
"Featured hashtags": "Hashtags em destaque",
"Proxy": "Proxy",
"Only allow replies from followers": "Permitir apenas respostas de seguidores"
"Only allow replies from followers": "Permitir apenas respostas de seguidores",
"Only allow replies from mutuals": "Permitir apenas respostas de mútuos"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "Показать сообщения для голосования",
"Featured hashtags": "Избранные хэштеги",
"Proxy": "Прокси",
"Only allow replies from followers": "Разрешить ответы только от подписчиков"
"Only allow replies from followers": "Разрешить ответы только от подписчиков",
"Only allow replies from mutuals": "Разрешить ответы только от взаимных"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "Onyesha machapisho ya kura",
"Featured hashtags": "Reli zilizoangaziwa",
"Proxy": "Wakala",
"Only allow replies from followers": "Ruhusu tu majibu kutoka kwa wafuasi"
"Only allow replies from followers": "Ruhusu tu majibu kutoka kwa wafuasi",
"Only allow replies from mutuals": "Ruhusu tu majibu kutoka kwa pande zote mbili"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "Oy gönderilerini göster",
"Featured hashtags": "Öne çıkan etiketler",
"Proxy": "Vekil",
"Only allow replies from followers": "Yalnızca takipçilerden gelen yanıtlara izin ver"
"Only allow replies from followers": "Yalnızca takipçilerden gelen yanıtlara izin ver",
"Only allow replies from mutuals": "Yalnızca ortaklardan gelen yanıtlara izin ver"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "Показати повідомлення про голосування",
"Featured hashtags": "Рекомендовані хештеги",
"Proxy": "Проксі",
"Only allow replies from followers": "Дозволити відповіді лише від підписників"
"Only allow replies from followers": "Дозволити відповіді лише від підписників",
"Only allow replies from mutuals": "Дозволити відповіді лише від взаємних клієнтів"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "ווייַזן שטימען אַרטיקלען",
"Featured hashtags": "פֿעיִקייטן פון hashtags",
"Proxy": "פראקסי",
"Only allow replies from followers": "נאָר לאָזן ענטפֿערס פון אנהענגערס"
"Only allow replies from followers": "נאָר לאָזן ענטפֿערס פון אנהענגערס",
"Only allow replies from mutuals": "לאָזן בלויז ענטפֿערס פון מיוטשואַלז"
}

View File

@ -624,5 +624,6 @@
"Show vote posts": "显示投票帖子",
"Featured hashtags": "特色标签",
"Proxy": "代理人",
"Only allow replies from followers": "只允许关注者回复"
"Only allow replies from followers": "只允许关注者回复",
"Only allow replies from mutuals": "只允许来自相互的回复"
}

View File

@ -2444,7 +2444,8 @@ def _html_edit_profile_options(is_admin: bool,
min_images_for_accounts: [],
reverse_sequence: [],
show_vote_posts: bool,
show_replies_followers: bool) -> str:
show_replies_followers: bool,
show_replies_mutuals: bool) -> str:
"""option checkboxes section of edit profile screen
"""
edit_profile_form = ' <div class="container">\n'
@ -2502,6 +2503,10 @@ def _html_edit_profile_options(is_admin: bool,
edit_profile_form += \
edit_check_box(show_replies_followers_str, 'repliesFromFollowersOnly',
show_replies_followers)
show_replies_mutuals_str = translate['Only allow replies from mutuals']
edit_profile_form += \
edit_check_box(show_replies_mutuals_str, 'repliesFromMutualsOnly',
show_replies_mutuals)
edit_profile_form += ' </div>\n'
return edit_profile_form
@ -2879,6 +2884,11 @@ def html_edit_profile(server, translate: {},
if os.path.isfile(account_dir + '/.repliesFromFollowersOnly'):
show_replies_followers = True
# only show replies from mutuals
show_replies_mutuals = False
if os.path.isfile(account_dir + '/.repliesFromMutualsOnly'):
show_replies_mutuals = True
# Option checkboxes
edit_profile_form += \
_html_edit_profile_options(is_admin, manually_approves_followers,
@ -2890,7 +2900,8 @@ def html_edit_profile(server, translate: {},
translate, bold_reading,
nickname, min_images_for_accounts,
reverse_sequence, show_vote_posts,
show_replies_followers)
show_replies_followers,
show_replies_mutuals)
# Contact information
edit_profile_form += \