diff --git a/daemon.py b/daemon.py index d232275cd..b732b8797 100644 --- a/daemon.py +++ b/daemon.py @@ -60,6 +60,7 @@ from utils import load_account_timezones from utils import load_translations_from_file from utils import load_bold_reading from utils import load_hide_follows +from utils import load_hide_recent_posts from utils import get_full_domain from utils import set_config_param from utils import get_config_param @@ -327,6 +328,7 @@ class EpicyonServer(ThreadingHTTPServer): preferred_podcast_formats: list[str] = [] bold_reading = {} hide_follows = {} + hide_recent_posts = {} account_timezone = None post_to_nickname = None nodeinfo_is_active = False @@ -856,6 +858,9 @@ def run_daemon(accounts_data_dir: str, # whether to hide follows on profile screen for each account httpd.hide_follows = load_hide_follows(base_dir) + # whether to hide recent public posts on profile screen for each account + httpd.hide_recent_posts = load_hide_recent_posts(base_dir) + httpd.account_timezone = load_account_timezones(base_dir) httpd.post_to_nickname = None diff --git a/daemon_get.py b/daemon_get.py index 27c8acdde..65ecea4c1 100644 --- a/daemon_get.py +++ b/daemon_get.py @@ -4706,7 +4706,8 @@ def daemon_http_get(self) -> None: self.server.fitness, self.server.onion_domain, self.server.i2p_domain, - self.server.mitm_servers): + self.server.mitm_servers, + self.server.hide_recent_posts): self.server.getreq_busy = False return @@ -4764,7 +4765,8 @@ def daemon_http_get(self) -> None: self.server.domain_full, self.server.onion_domain, self.server.i2p_domain, - self.server.mitm_servers): + self.server.mitm_servers, + self.server.hide_recent_posts): self.server.getreq_busy = False return @@ -5622,7 +5624,8 @@ def daemon_http_get(self) -> None: self.server.onion_domain, self.server.i2p_domain, self.server.hide_announces, - self.server.mitm_servers): + self.server.mitm_servers, + self.server.hide_recent_posts): self.server.getreq_busy = False return @@ -5741,7 +5744,8 @@ def daemon_http_get(self) -> None: self.server.fitness, self.server.onion_domain, self.server.i2p_domain, - self.server.mitm_servers): + self.server.mitm_servers, + self.server.hide_recent_posts): self.server.getreq_busy = False return @@ -5799,7 +5803,8 @@ def daemon_http_get(self) -> None: self.server.fitness, self.server.onion_domain, self.server.i2p_domain, - self.server.mitm_servers): + self.server.mitm_servers, + self.server.hide_recent_posts): self.server.getreq_busy = False return @@ -5856,7 +5861,8 @@ def daemon_http_get(self) -> None: self.server.fitness, self.server.onion_domain, self.server.i2p_domain, - self.server.mitm_servers): + self.server.mitm_servers, + self.server.hide_recent_posts): self.server.getreq_busy = False return @@ -5914,7 +5920,8 @@ def daemon_http_get(self) -> None: self.server.fitness, self.server.onion_domain, self.server.i2p_domain, - self.server.mitm_servers): + self.server.mitm_servers, + self.server.hide_recent_posts): self.server.getreq_busy = False return @@ -5972,7 +5979,8 @@ def daemon_http_get(self) -> None: self.server.fitness, self.server.onion_domain, self.server.i2p_domain, - self.server.mitm_servers): + self.server.mitm_servers, + self.server.hide_recent_posts): self.server.getreq_busy = False return @@ -6029,7 +6037,8 @@ def daemon_http_get(self) -> None: self.server.buy_sites, self.server.no_of_books, self.server.auto_cw_cache, - self.server.mitm_servers): + self.server.mitm_servers, + self.server.hide_recent_posts): self.server.getreq_busy = False return diff --git a/daemon_get_feeds.py b/daemon_get_feeds.py index 383033d65..98a1ce20c 100644 --- a/daemon_get_feeds.py +++ b/daemon_get_feeds.py @@ -70,7 +70,8 @@ def show_shares_feed(self, authorized: bool, fitness: {}, onion_domain: str, i2p_domain: str, - mitm_servers: []) -> bool: + mitm_servers: [], + hide_recent_posts: {}) -> bool: """Shows the shares feed for a particular account/actor """ shares = \ @@ -174,7 +175,8 @@ def show_shares_feed(self, authorized: bool, auto_cw_cache, known_epicyon_instances, mitm_servers, - instance_software) + instance_software, + hide_recent_posts) msg = msg.encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, @@ -257,7 +259,8 @@ def show_following_feed(self, authorized: bool, fitness: {}, onion_domain: str, i2p_domain: str, - mitm_servers: []) -> bool: + mitm_servers: [], + hide_recent_posts: {}) -> bool: """Shows the following feed for a particular account/actor """ following = \ @@ -368,7 +371,8 @@ def show_following_feed(self, authorized: bool, auto_cw_cache, known_epicyon_instances, mitm_servers, - instance_software).encode('utf-8') + instance_software, + hide_recent_posts).encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, cookie, calling_domain, False) @@ -457,7 +461,8 @@ def show_moved_feed(self, authorized: bool, fitness: {}, onion_domain: str, i2p_domain: str, - mitm_servers: []) -> bool: + mitm_servers: [], + hide_recent_posts: {}) -> bool: """Shows the moved feed for a particular account/actor """ following = \ @@ -563,7 +568,8 @@ def show_moved_feed(self, authorized: bool, auto_cw_cache, known_epicyon_instances, mitm_servers, - instance_software).encode('utf-8') + instance_software, + hide_recent_posts).encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, cookie, calling_domain, False) @@ -644,7 +650,8 @@ def show_inactive_feed(self, authorized: bool, fitness: {}, onion_domain: str, i2p_domain: str, - mitm_servers: []) -> bool: + mitm_servers: [], + hide_recent_posts: {}) -> bool: """Shows the inactive accounts feed for a particular account/actor """ following = \ @@ -751,7 +758,8 @@ def show_inactive_feed(self, authorized: bool, auto_cw_cache, known_epicyon_instances, mitm_servers, - instance_software).encode('utf-8') + instance_software, + hide_recent_posts).encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, cookie, calling_domain, False) @@ -834,7 +842,8 @@ def show_followers_feed(self, authorized: bool, fitness: {}, onion_domain: str, i2p_domain: str, - mitm_servers: []) -> bool: + mitm_servers: [], + hide_recent_posts: {}) -> bool: """Shows the followers feed for a particular account/actor """ followers = \ @@ -942,7 +951,8 @@ def show_followers_feed(self, authorized: bool, auto_cw_cache, known_epicyon_instances, mitm_servers, - instance_software).encode('utf-8') + instance_software, + hide_recent_posts).encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, cookie, calling_domain, False) diff --git a/daemon_get_profile.py b/daemon_get_profile.py index ab00c61c7..dc52da0a9 100644 --- a/daemon_get_profile.py +++ b/daemon_get_profile.py @@ -79,7 +79,8 @@ def show_person_profile(self, authorized: bool, buy_sites: [], no_of_books: int, auto_cw_cache: {}, - mitm_servers: []) -> bool: + mitm_servers: [], + hide_recent_posts: {}) -> bool: """Shows the profile for a person """ # look up a person @@ -155,7 +156,8 @@ def show_person_profile(self, authorized: bool, auto_cw_cache, known_epicyon_instances, mitm_servers, - instance_software).encode('utf-8') + instance_software, + hide_recent_posts).encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, cookie, calling_domain, False) @@ -239,7 +241,8 @@ def show_roles(self, calling_domain: str, referer_domain: str, fitness: {}, onion_domain: str, i2p_domain: str, - mitm_servers: []) -> bool: + mitm_servers: [], + hide_recent_posts: {}) -> bool: """Show roles within profile screen """ named_status = path.split('/users/')[1] @@ -318,7 +321,8 @@ def show_roles(self, calling_domain: str, referer_domain: str, auto_cw_cache, known_epicyon_instances, mitm_servers, - instance_software) + instance_software, + hide_recent_posts) msg = msg.encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, @@ -394,7 +398,8 @@ def show_skills(self, calling_domain: str, referer_domain: str, domain_full: str, onion_domain: str, i2p_domain: str, - mitm_servers: []) -> bool: + mitm_servers: [], + hide_recent_posts: {}) -> bool: """Show skills on the profile screen """ named_status = path.split('/users/')[1] @@ -475,7 +480,8 @@ def show_skills(self, calling_domain: str, referer_domain: str, auto_cw_cache, known_epicyon_instances, mitm_servers, - instance_software) + instance_software, + hide_recent_posts) msg = msg.encode('utf-8') msglen = len(msg) set_headers(self, 'text/html', msglen, diff --git a/daemon_get_timeline.py b/daemon_get_timeline.py index 69b1487d2..0783de3cf 100644 --- a/daemon_get_timeline.py +++ b/daemon_get_timeline.py @@ -1459,9 +1459,19 @@ def show_outbox_timeline(self, authorized: bool, onion_domain: str, i2p_domain: str, hide_announces: {}, - mitm_servers: []) -> bool: + mitm_servers: [], + hide_recent_posts: {}) -> bool: """Shows the outbox timeline """ + nickname = \ + path.replace('/users/', '').replace('/outbox', '') + + # if recent posts are hidden then return 404 + if nickname: + if not authorized and hide_recent_posts.get(nickname): + http_404(self, 77) + return True + # get outbox feed for a person outbox_feed = \ person_box_json(recent_posts_cache, @@ -1472,8 +1482,6 @@ def show_outbox_timeline(self, authorized: bool, positive_voting, voting_time_mins) if outbox_feed: - nickname = \ - path.replace('/users/', '').replace('/outbox', '') page_number = 0 if '?page=' in nickname: page_number = nickname.split('?page=')[1] diff --git a/daemon_post_profile.py b/daemon_post_profile.py index bb6c8bae9..ed7d2e14d 100644 --- a/daemon_post_profile.py +++ b/daemon_post_profile.py @@ -1037,12 +1037,52 @@ def _profile_post_hide_follows(base_dir: str, nickname: str, domain: str, try: os.remove(hide_follows_filename) except OSError: - print('EX: _profile_edit ' + + print('EX: _profile_post_hide_follows ' + 'unable to delete ' + hide_follows_filename) return actor_changed +def _profile_post_hide_recent_posts(base_dir: str, nickname: str, domain: str, + actor_json: {}, fields: {}, self, + actor_changed: bool, + premium: bool) -> bool: + """ HTTP POST hide recent public posts checkbox + This hides public posts from unauthorized viewers + """ + hide_recent_posts_filename = \ + acct_dir(base_dir, nickname, domain) + '/.hideRecentPosts' + hide_recent_posts = premium + if fields.get('hideRecentPosts'): + if fields['hideRecentPosts'] == 'on': + hide_recent_posts = True + if hide_recent_posts: + self.server.hide_recent_posts[nickname] = True + actor_json['hideRecentPosts'] = True + actor_changed = True + if not os.path.isfile(hide_recent_posts_filename): + try: + with open(hide_recent_posts_filename, 'w+', + encoding='utf-8') as fp_hide: + fp_hide.write('\n') + except OSError: + print('EX: unable to write hideRecentPosts ' + + hide_recent_posts_filename) + if not hide_recent_posts: + actor_json['hideRecentPosts'] = False + if self.server.hide_recent_posts.get(nickname): + del self.server.hide_recent_posts[nickname] + actor_changed = True + if os.path.isfile(hide_recent_posts_filename): + try: + os.remove(hide_recent_posts_filename) + except OSError: + print('EX: _profile_post_hide_recent_posts ' + + 'unable to delete ' + + hide_recent_posts_filename) + return actor_changed + + def _profile_post_mutuals_replies(account_dir: str, fields: {}) -> None: """ HTTP POST show replies only from mutuals checkbox """ @@ -3325,6 +3365,10 @@ def profile_edit(self, calling_domain: str, cookie: str, _profile_post_hide_follows(base_dir, nickname, domain, actor_json, fields, self, actor_changed, premium) + actor_changed = \ + _profile_post_hide_recent_posts(base_dir, nickname, domain, + actor_json, fields, self, + actor_changed, premium) _profile_post_block_military(nickname, fields, self) _profile_post_block_government(nickname, fields, self) _profile_post_block_bluesky(nickname, fields, self) diff --git a/translations/ar.json b/translations/ar.json index 156c975c3..c64338b8f 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "وسائل الإعلام الممولة من الدولة الروسية", "Satire": "هجاء", "UK Right Wing Think Tank": "مركز أبحاث يميني متطرف في المملكة المتحدة", - "DeltaChat": "دعوة إلى DeltaChat" + "DeltaChat": "دعوة إلى DeltaChat", + "Don't show recent public posts on your profile": "لا تعرض المنشورات العامة الأخيرة على ملفك الشخصي" } diff --git a/translations/bn.json b/translations/bn.json index 854a95561..a492b04cc 100644 --- a/translations/bn.json +++ b/translations/bn.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "রাশিয়ান রাষ্ট্র অর্থায়ন মিডিয়া", "Satire": "ব্যঙ্গ", "UK Right Wing Think Tank": "ইউকে রাইট উইং থিঙ্ক ট্যাঙ্ক", - "DeltaChat": "ডেল্টাচ্যাট আমন্ত্রণ" + "DeltaChat": "ডেল্টাচ্যাট আমন্ত্রণ", + "Don't show recent public posts on your profile": "আপনার প্রোফাইলে সাম্প্রতিক পাবলিক পোস্টগুলি দেখাবেন না" } diff --git a/translations/ca.json b/translations/ca.json index 339d41ff9..65e4830ee 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "Mitjans de comunicació finançats per l'estat rus", "Satire": "Sàtira", "UK Right Wing Think Tank": "Think Tank de la dreta del Regne Unit", - "DeltaChat": "Invitació de DeltaChat" + "DeltaChat": "Invitació de DeltaChat", + "Don't show recent public posts on your profile": "No mostris publicacions públiques recents al teu perfil" } diff --git a/translations/cy.json b/translations/cy.json index 072b97ccb..a901ae2c7 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "Cyfryngau a Ariennir gan Wladwriaeth Rwseg", "Satire": "Dychan", "UK Right Wing Think Tank": "Melin Drafod Adain Dde y DU", - "DeltaChat": "Gwahoddiad DeltaChat" + "DeltaChat": "Gwahoddiad DeltaChat", + "Don't show recent public posts on your profile": "Peidiwch â dangos postiadau cyhoeddus diweddar ar eich proffil" } diff --git a/translations/de.json b/translations/de.json index 3923b7d30..130e992d4 100644 --- a/translations/de.json +++ b/translations/de.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "Russische staatlich finanzierte Medien", "Satire": "Satire", "UK Right Wing Think Tank": "Britischer Thinktank mit rechter Front", - "DeltaChat": "DeltaChat-Einladung" + "DeltaChat": "DeltaChat-Einladung", + "Don't show recent public posts on your profile": "Zeigen Sie keine aktuellen öffentlichen Beiträge in Ihrem Profil an" } diff --git a/translations/el.json b/translations/el.json index cb6a35baf..2d226cbd8 100644 --- a/translations/el.json +++ b/translations/el.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "Ρωσικά κρατικά χρηματοδοτούμενα ΜΜΕ", "Satire": "Σάτυρα", "UK Right Wing Think Tank": "Δεξαμενή Σκέψης Δεξιάς στο Ηνωμένο Βασίλειο", - "DeltaChat": "Πρόσκληση DeltaChat" + "DeltaChat": "Πρόσκληση DeltaChat", + "Don't show recent public posts on your profile": "Μην εμφανίζετε πρόσφατες δημόσιες αναρτήσεις στο προφίλ σας" } diff --git a/translations/en.json b/translations/en.json index 468e7745c..2e995235c 100644 --- a/translations/en.json +++ b/translations/en.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "Russian State Funded Media", "Satire": "Satire", "UK Right Wing Think Tank": "UK Right Wing Think Tank", - "DeltaChat": "DeltaChat invite" + "DeltaChat": "DeltaChat invite", + "Don't show recent public posts on your profile": "Don't show recent public posts on your profile" } diff --git a/translations/es.json b/translations/es.json index 0d1954f09..bafbe4554 100644 --- a/translations/es.json +++ b/translations/es.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "Medios de comunicación financiados por el Estado ruso", "Satire": "Sátira", "UK Right Wing Think Tank": "Centro de estudios de derecha del Reino Unido", - "DeltaChat": "Invitación a DeltaChat" + "DeltaChat": "Invitación a DeltaChat", + "Don't show recent public posts on your profile": "No mostrar publicaciones públicas recientes en tu perfil" } diff --git a/translations/fa.json b/translations/fa.json index bfb302590..823f9e067 100644 --- a/translations/fa.json +++ b/translations/fa.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "رسانه های دولتی روسیه", "Satire": "طنز", "UK Right Wing Think Tank": "اتاق فکر جناح راست انگلستان", - "DeltaChat": "دعوت از دلتا چت" + "DeltaChat": "دعوت از دلتا چت", + "Don't show recent public posts on your profile": "پست های عمومی اخیر را در نمایه خود نشان ندهید" } diff --git a/translations/fi.json b/translations/fi.json index 0b9648ffc..71eef397f 100644 --- a/translations/fi.json +++ b/translations/fi.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "Venäjän valtion rahoittama media", "Satire": "Satiiri", "UK Right Wing Think Tank": "Ison-Britannian oikeanpuoleinen ajatushautomo", - "DeltaChat": "DeltaChat-kutsu" + "DeltaChat": "DeltaChat-kutsu", + "Don't show recent public posts on your profile": "Älä näytä viimeisimmät julkiset viestit profiilissasi" } diff --git a/translations/fr.json b/translations/fr.json index 28b566333..ad7a15eb3 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "Médias financés par l'État russe", "Satire": "Satire", "UK Right Wing Think Tank": "Groupe de réflexion de droite britannique", - "DeltaChat": "Invitation DeltaChat" + "DeltaChat": "Invitation DeltaChat", + "Don't show recent public posts on your profile": "Ne pas afficher les publications publiques récentes sur votre profil" } diff --git a/translations/ga.json b/translations/ga.json index b4f53a17b..0628a3af2 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "Meáin Mhaoinithe Stáit na Rúise", "Satire": "Aoir", "UK Right Wing Think Tank": "Umar Smaointeoireachta Sciathán Deis na Ríochta Aontaithe", - "DeltaChat": "Cuireadh DeltaChat" + "DeltaChat": "Cuireadh DeltaChat", + "Don't show recent public posts on your profile": "Ná taispeáin postálacha poiblí le déanaí ar do phróifíl" } diff --git a/translations/he.json b/translations/he.json index 634fb0be6..eb48d6c03 100644 --- a/translations/he.json +++ b/translations/he.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "מדיה במימון המדינה הרוסית", "Satire": "סָאטִירָה", "UK Right Wing Think Tank": "טנק חשיבה ימני בבריטניה", - "DeltaChat": "הזמנת DeltaChat" + "DeltaChat": "הזמנת DeltaChat", + "Don't show recent public posts on your profile": "אל תציג פוסטים ציבוריים אחרונים בפרופיל שלך" } diff --git a/translations/hi.json b/translations/hi.json index 464cfa25e..341e4a280 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "रूसी राज्य वित्तपोषित मीडिया", "Satire": "हास्य व्यंग्य", "UK Right Wing Think Tank": "यू.के. दक्षिणपंथी थिंक टैंक", - "DeltaChat": "डेल्टाचैट आमंत्रण" + "DeltaChat": "डेल्टाचैट आमंत्रण", + "Don't show recent public posts on your profile": "अपनी प्रोफ़ाइल पर हाल ही की सार्वजनिक पोस्ट न दिखाएँ" } diff --git a/translations/it.json b/translations/it.json index 0f0ae371e..63640479b 100644 --- a/translations/it.json +++ b/translations/it.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "Media finanziati dallo Stato russo", "Satire": "Satira", "UK Right Wing Think Tank": "Think Tank di destra nel Regno Unito", - "DeltaChat": "Invito DeltaChat" + "DeltaChat": "Invito DeltaChat", + "Don't show recent public posts on your profile": "Non mostrare i post pubblici recenti sul tuo profilo" } diff --git a/translations/ja.json b/translations/ja.json index 397f95cba..01081cd9e 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "ロシアの国営メディア", "Satire": "風刺", "UK Right Wing Think Tank": "英国右派シンクタンク", - "DeltaChat": "DeltaChat 招待" + "DeltaChat": "DeltaChat 招待", + "Don't show recent public posts on your profile": "プロフィールに最近の公開投稿を表示しない" } diff --git a/translations/ko.json b/translations/ko.json index dbe6f1b6c..14ee27895 100644 --- a/translations/ko.json +++ b/translations/ko.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "러시아 국가가 자금을 지원하는 미디어", "Satire": "풍자", "UK Right Wing Think Tank": "영국 우익 싱크탱크", - "DeltaChat": "DeltaChat 초대" + "DeltaChat": "DeltaChat 초대", + "Don't show recent public posts on your profile": "프로필에 최근 공개 게시물을 표시하지 마세요" } diff --git a/translations/ku.json b/translations/ku.json index cb5f322f3..685206ea6 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "Medyaya Fînansekirî ya Dewleta Rûsyayê", "Satire": "Satire", "UK Right Wing Think Tank": "Tanka Fikirê ya Rastê ya Brîtanyayê", - "DeltaChat": "vexwendina DeltaChat" + "DeltaChat": "vexwendina DeltaChat", + "Don't show recent public posts on your profile": "Mesajên giştî yên dawî li ser profîla xwe nîşan nedin" } diff --git a/translations/nl.json b/translations/nl.json index 3bc7eb5d2..8df06c1c6 100644 --- a/translations/nl.json +++ b/translations/nl.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "Russische staatsgefinancierde media", "Satire": "Satire", "UK Right Wing Think Tank": "Britse rechtse denktank", - "DeltaChat": "DeltaChat-uitnodiging" + "DeltaChat": "DeltaChat-uitnodiging", + "Don't show recent public posts on your profile": "Toon geen recente openbare berichten op uw profiel" } diff --git a/translations/oc.json b/translations/oc.json index e10c2961c..efe8cca0f 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -716,5 +716,6 @@ "Russian State Funded Media": "Russian State Funded Media", "Satire": "Satire", "UK Right Wing Think Tank": "UK Right Wing Think Tank", - "DeltaChat": "DeltaChat invite" + "DeltaChat": "DeltaChat invite", + "Don't show recent public posts on your profile": "Don't show recent public posts on your profile" } diff --git a/translations/pl.json b/translations/pl.json index 62104fe18..c20d789d7 100644 --- a/translations/pl.json +++ b/translations/pl.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "Rosyjskie media finansowane przez państwo", "Satire": "Satyra", "UK Right Wing Think Tank": "Brytyjski prawicowy think tank", - "DeltaChat": "Zaproszenie do DeltaChat" + "DeltaChat": "Zaproszenie do DeltaChat", + "Don't show recent public posts on your profile": "Nie pokazuj ostatnich publicznych postów na swoim profilu" } diff --git a/translations/pt.json b/translations/pt.json index 673049b89..4daf9d5e8 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "Comunicação social financiada pelo Estado russo", "Satire": "Sátira", "UK Right Wing Think Tank": "Think Tank de direita do Reino Unido", - "DeltaChat": "Convite DeltaChat" + "DeltaChat": "Convite DeltaChat", + "Don't show recent public posts on your profile": "Não mostrar publicações públicas recentes no seu perfil" } diff --git a/translations/ru.json b/translations/ru.json index ca5e4f21d..7fbb4d40e 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "Российские государственные СМИ", "Satire": "Сатира", "UK Right Wing Think Tank": "Британский правый аналитический центр", - "DeltaChat": "Приглашение DeltaChat" + "DeltaChat": "Приглашение DeltaChat", + "Don't show recent public posts on your profile": "Не показывать последние публичные публикации в вашем профиле" } diff --git a/translations/sw.json b/translations/sw.json index cd58c5861..9991e7e6c 100644 --- a/translations/sw.json +++ b/translations/sw.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "Vyombo vya Habari vinavyofadhiliwa na Serikali ya Urusi", "Satire": "Satire", "UK Right Wing Think Tank": "Uingereza Right Wing Think Tank", - "DeltaChat": "mwaliko wa DeltaChat" + "DeltaChat": "mwaliko wa DeltaChat", + "Don't show recent public posts on your profile": "Usionyeshe machapisho ya hivi majuzi ya umma kwenye wasifu wako" } diff --git a/translations/tr.json b/translations/tr.json index 9faae5031..9eceb4580 100644 --- a/translations/tr.json +++ b/translations/tr.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "Rusya Devleti Tarafından Finanse Edilen Medya", "Satire": "Hiciv", "UK Right Wing Think Tank": "İngiltere Sağ Kanat Düşünce Kuruluşu", - "DeltaChat": "DeltaChat daveti" + "DeltaChat": "DeltaChat daveti", + "Don't show recent public posts on your profile": "Profilinizde son genel paylaşımları göstermeyin" } diff --git a/translations/uk.json b/translations/uk.json index ddcf4dc27..f6240483d 100644 --- a/translations/uk.json +++ b/translations/uk.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "Російські державні ЗМІ", "Satire": "Сатира", "UK Right Wing Think Tank": "Британський правий мозковий центр", - "DeltaChat": "Запрошення DeltaChat" + "DeltaChat": "Запрошення DeltaChat", + "Don't show recent public posts on your profile": "Не показувати останні загальнодоступні публікації у своєму профілі" } diff --git a/translations/yi.json b/translations/yi.json index c618aff13..cfcb87a0b 100644 --- a/translations/yi.json +++ b/translations/yi.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "רוסיש שטאַט פאַנדאַד מידיאַ", "Satire": "סאַטירע", "UK Right Wing Think Tank": "וק רעכט פליגל טראַכטן טאַנק", - "DeltaChat": "דעלטאַטשאַט פאַרבעטן" + "DeltaChat": "דעלטאַטשאַט פאַרבעטן", + "Don't show recent public posts on your profile": "צי ניט ווייַזן לעצטע עפנטלעך הודעות אויף דיין פּראָפיל" } diff --git a/translations/zh.json b/translations/zh.json index c815e5390..a6ea29f17 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -720,5 +720,6 @@ "Russian State Funded Media": "俄罗斯国家资助的媒体", "Satire": "讽刺", "UK Right Wing Think Tank": "英国右翼智库", - "DeltaChat": "DeltaChat 邀请" + "DeltaChat": "DeltaChat 邀请", + "Don't show recent public posts on your profile": "不要在你的个人资料上显示最近的公开帖子" } diff --git a/utils.py b/utils.py index c9841fbb2..4f453f8c8 100644 --- a/utils.py +++ b/utils.py @@ -4262,6 +4262,27 @@ def load_hide_follows(base_dir: str) -> {}: return hide_follows +def load_hide_recent_posts(base_dir: str) -> {}: + """Returns a dictionary containing the hide recent posts status + for each account + """ + hide_recent_posts = {} + dir_str = data_dir(base_dir) + for _, dirs, _ in os.walk(dir_str): + for acct in dirs: + if '@' not in acct: + continue + if acct.startswith('inbox@') or acct.startswith('Actor@'): + continue + hide_recent_posts_filename = \ + dir_str + '/' + acct + '/.hideRecentPosts' + if os.path.isfile(hide_recent_posts_filename): + nickname = acct.split('@')[0] + hide_recent_posts[nickname] = True + break + return hide_recent_posts + + def get_account_timezone(base_dir: str, nickname: str, domain: str) -> str: """Returns the timezone for the given account """ diff --git a/webapp_profile.py b/webapp_profile.py index 225b7deae..4ae1880f3 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -1045,7 +1045,8 @@ def html_profile(signing_priv_key_pem: str, auto_cw_cache: {}, known_epicyon_instances: [], mitm_servers: [], - instance_software: {}) -> str: + instance_software: {}, + hide_recent_posts: {}) -> str: """Show the profile page as html """ show_moved_accounts = False @@ -1637,8 +1638,11 @@ def html_profile(signing_priv_key_pem: str, translate['Get the source code'] + '" src="/icons/agpl.png" />' if selected == 'posts' and not premium: - max_profile_posts = \ - get_max_profile_posts(base_dir, nickname, domain, 20) + if hide_recent_posts.get(nickname): + max_profile_posts = 0 + else: + max_profile_posts = \ + get_max_profile_posts(base_dir, nickname, domain, 20) min_images_for_accounts: list[str] = [] profile_str += \ _html_profile_posts(recent_posts_cache, max_profile_posts, @@ -3055,6 +3059,7 @@ def _html_edit_profile_options(is_admin: bool, show_quote_toots: bool, show_vote_posts: bool, hide_follows: bool, + hide_recent_posts: bool, premium: bool, no_seen_posts: bool, watermark_enabled: bool) -> str: @@ -3128,6 +3133,12 @@ def _html_edit_profile_options(is_admin: bool, edit_profile_form += \ edit_check_box(hide_follows_str, 'hideFollows', hide_follows) + hide_recent_posts_str = \ + translate["Don't show recent public posts on your profile"] + edit_profile_form += \ + edit_check_box(hide_recent_posts_str, 'hideRecentPosts', + hide_recent_posts) + no_seen_posts_str = translate["Don't show already seen posts"] edit_profile_form += \ edit_check_box(no_seen_posts_str, 'noSeenPosts', no_seen_posts) @@ -3574,6 +3585,11 @@ def html_edit_profile(server, translate: {}, if os.path.isfile(account_dir + '/.hideFollows'): hide_follows = True + # don't show recent public posts on profile + hide_recent_posts = False + if os.path.isfile(account_dir + '/.hideRecentPosts'): + hide_recent_posts = True + # is this a premium account? premium = is_premium_account(base_dir, nickname, domain) @@ -3606,7 +3622,8 @@ def html_edit_profile(server, translate: {}, min_images_for_accounts, reverse_sequence, show_quote_toots, show_vote_posts, hide_follows, - premium, no_seen_posts, watermark_enabled) + hide_recent_posts, premium, + no_seen_posts, watermark_enabled) # reply controls edit_profile_form += \