From 410a77c98a8830c9eb7f4a97bd905984d7ae81c9 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 9 Sep 2022 21:02:27 +0100 Subject: [PATCH] Option to enable spam filtering of actors --- daemon.py | 26 ++++++++++++++++++++++++++ translations/ar.json | 3 ++- translations/bn.json | 3 ++- translations/ca.json | 3 ++- translations/cy.json | 3 ++- translations/de.json | 3 ++- translations/el.json | 3 ++- translations/en.json | 3 ++- translations/es.json | 3 ++- translations/fr.json | 3 ++- translations/ga.json | 3 ++- translations/hi.json | 3 ++- translations/it.json | 3 ++- translations/ja.json | 3 ++- translations/ko.json | 3 ++- translations/ku.json | 3 ++- translations/nl.json | 3 ++- translations/oc.json | 3 ++- translations/pl.json | 3 ++- translations/pt.json | 3 ++- translations/ru.json | 3 ++- translations/sw.json | 3 ++- translations/tr.json | 3 ++- translations/uk.json | 3 ++- translations/yi.json | 3 ++- translations/zh.json | 3 ++- webapp_profile.py | 13 ++++++++++++- 27 files changed, 88 insertions(+), 26 deletions(-) diff --git a/daemon.py b/daemon.py index 784d041d0..12919075e 100644 --- a/daemon.py +++ b/daemon.py @@ -6612,6 +6612,32 @@ class PubServer(BaseHTTPRequestHandler): approve_followers actor_changed = True + # reject spam actors + reject_spam_actors = False + if fields.get('rejectSpamActors'): + if fields['rejectSpamActors'] == 'on': + reject_spam_actors = True + curr_reject_spam_actors = False + actor_spam_filter_filename = \ + acct_dir(base_dir, nickname, domain) + \ + '/.reject_spam_actors' + if os.path.isfile(actor_spam_filter_filename): + curr_reject_spam_actors = True + if reject_spam_actors != curr_reject_spam_actors: + if reject_spam_actors: + try: + with open(actor_spam_filter_filename, 'w+', + encoding='utf-8') as fp_spam: + fp_spam.write('\n') + except OSError: + print('EX: unable to write reject spam actors') + else: + try: + os.remove(actor_spam_filter_filename) + except OSError: + print('EX: ' + + 'unable to remove reject spam actors') + # keep DMs during post expiry expire_keep_dms = False if fields.get('expiryKeepDMs'): diff --git a/translations/ar.json b/translations/ar.json index 39f77aa6c..cae264998 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -593,5 +593,6 @@ "Credentials are too long": "أوراق الاعتماد طويلة جدًا", "Site DevOps": "DevOps الموقع", "A list of devops nicknames. One per line.": "قائمة بأسماء المطورين. واحد في كل سطر.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/bn.json b/translations/bn.json index 82d5a110f..987f9c454 100644 --- a/translations/bn.json +++ b/translations/bn.json @@ -593,5 +593,6 @@ "Credentials are too long": "শংসাপত্রগুলি খুব দীর্ঘ৷", "Site DevOps": "সাইট DevOps", "A list of devops nicknames. One per line.": "ডেভপস ডাকনামের একটি তালিকা। প্রতি লাইনে একটি।", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/ca.json b/translations/ca.json index a2a59a06e..bb2eedd8f 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -593,5 +593,6 @@ "Credentials are too long": "Les credencials són massa llargues", "Site DevOps": "Lloc DevOps", "A list of devops nicknames. One per line.": "Una llista de sobrenoms de devops. Un per línia.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/cy.json b/translations/cy.json index 39e1cbf74..e1a407932 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -593,5 +593,6 @@ "Credentials are too long": "Mae manylion yn rhy hir", "Site DevOps": "Gwefan DevOps", "A list of devops nicknames. One per line.": "Mae rhestr o devops llysenwau. Un i bob llinell.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/de.json b/translations/de.json index ed54dc3ae..656d93c3e 100644 --- a/translations/de.json +++ b/translations/de.json @@ -593,5 +593,6 @@ "Credentials are too long": "Anmeldeinformationen sind zu lang", "Site DevOps": "Site-DevOps", "A list of devops nicknames. One per line.": "Eine Liste von Entwickler-Spitznamen. Eine pro Zeile.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/el.json b/translations/el.json index ad9240814..9b4af36b8 100644 --- a/translations/el.json +++ b/translations/el.json @@ -593,5 +593,6 @@ "Credentials are too long": "Τα διαπιστευτήρια είναι πολύ μεγάλα", "Site DevOps": "DevOps ιστότοπου", "A list of devops nicknames. One per line.": "Μια λίστα με ψευδώνυμα devops. Ένα ανά γραμμή.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/en.json b/translations/en.json index d6967f0b6..1d7e6ea76 100644 --- a/translations/en.json +++ b/translations/en.json @@ -593,5 +593,6 @@ "Credentials are too long": "Credentials are too long", "Site DevOps": "Site DevOps", "A list of devops nicknames. One per line.": "A list of devops nicknames. One per line.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/es.json b/translations/es.json index 06df4acf8..dce834978 100644 --- a/translations/es.json +++ b/translations/es.json @@ -593,5 +593,6 @@ "Credentials are too long": "Las credenciales son demasiado largas", "Site DevOps": "DevOps del sitio", "A list of devops nicknames. One per line.": "Una lista de apodos de devops. Uno por línea.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/fr.json b/translations/fr.json index 429424bea..2299e92c0 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -593,5 +593,6 @@ "Credentials are too long": "Les identifiants sont trop longs", "Site DevOps": "DevOps du site", "A list of devops nicknames. One per line.": "Une liste de surnoms de devops. Un par ligne.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/ga.json b/translations/ga.json index bb98400ce..ad610de9c 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -593,5 +593,6 @@ "Credentials are too long": "Tá dintiúir ró-fhada", "Site DevOps": "Suíomh DevOps", "A list of devops nicknames. One per line.": "Tá liosta devops leasainmneacha. Ceann in aghaidh an líne.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/hi.json b/translations/hi.json index 175af9375..f7fefc609 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -593,5 +593,6 @@ "Credentials are too long": "क्रेडेंशियल बहुत लंबे हैं", "Site DevOps": "साइट देवऑप्स", "A list of devops nicknames. One per line.": "देवोप्स उपनामों की एक सूची। प्रति पंक्ति एक।", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/it.json b/translations/it.json index 797328064..8605fa322 100644 --- a/translations/it.json +++ b/translations/it.json @@ -593,5 +593,6 @@ "Credentials are too long": "Le credenziali sono troppo lunghe", "Site DevOps": "Sito DevOps", "A list of devops nicknames. One per line.": "Un elenco di soprannomi devops. Uno per riga.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/ja.json b/translations/ja.json index a54397066..d4cfc964a 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -593,5 +593,6 @@ "Credentials are too long": "資格情報が長すぎます", "Site DevOps": "サイト DevOps", "A list of devops nicknames. One per line.": "DevOps ニックネームのリスト。 1 行に 1 つ。", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/ko.json b/translations/ko.json index b6d213910..2a9b3ce16 100644 --- a/translations/ko.json +++ b/translations/ko.json @@ -593,5 +593,6 @@ "Credentials are too long": "자격 증명이 너무 깁니다.", "Site DevOps": "사이트 DevOps", "A list of devops nicknames. One per line.": "데브옵스 닉네임 목록입니다. 한 줄에 하나씩.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/ku.json b/translations/ku.json index 9eb1d5a5b..59b75f208 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -593,5 +593,6 @@ "Credentials are too long": "Bawernameyên pir dirêj in", "Site DevOps": "Malpera DevOps", "A list of devops nicknames. One per line.": "Lîsteya navên devops. Her rêzek yek.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/nl.json b/translations/nl.json index 5f3fdbf05..38c9b5a41 100644 --- a/translations/nl.json +++ b/translations/nl.json @@ -593,5 +593,6 @@ "Credentials are too long": "Inloggegevens zijn te lang", "Site DevOps": "Site DevOps", "A list of devops nicknames. One per line.": "Een lijst met devops-bijnamen. Een per regel.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/oc.json b/translations/oc.json index 2922914c8..f120bf671 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -589,5 +589,6 @@ "Credentials are too long": "Credentials are too long", "Site DevOps": "Site DevOps", "A list of devops nicknames. One per line.": "A list of devops nicknames. One per line.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/pl.json b/translations/pl.json index 71449c430..6123fc0b0 100644 --- a/translations/pl.json +++ b/translations/pl.json @@ -593,5 +593,6 @@ "Credentials are too long": "Poświadczenia są za długie", "Site DevOps": "Deweloperzy witryny", "A list of devops nicknames. One per line.": "Lista pseudonimów Devopa. Jeden na linię.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/pt.json b/translations/pt.json index 7fecd5e19..c7d091a08 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -593,5 +593,6 @@ "Credentials are too long": "As credenciais são muito longas", "Site DevOps": "Site DevOps", "A list of devops nicknames. One per line.": "Uma lista de apelidos de devops. Um por linha.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/ru.json b/translations/ru.json index 1b2d22ae7..2296180b9 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -593,5 +593,6 @@ "Credentials are too long": "Учетные данные слишком длинные", "Site DevOps": "DevOps сайта", "A list of devops nicknames. One per line.": "Список псевдонимов devops. По одному на строку.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/sw.json b/translations/sw.json index caedc04fa..ec351ddf1 100644 --- a/translations/sw.json +++ b/translations/sw.json @@ -593,5 +593,6 @@ "Credentials are too long": "Kitambulisho ni kirefu sana", "Site DevOps": "Tovuti ya DevOps", "A list of devops nicknames. One per line.": "Orodha ya majina ya utani ya devops. Moja kwa kila mstari.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/tr.json b/translations/tr.json index e8ab86a9b..87948ae22 100644 --- a/translations/tr.json +++ b/translations/tr.json @@ -593,5 +593,6 @@ "Credentials are too long": "Kimlik bilgileri çok uzun", "Site DevOps": "Site DevOps", "A list of devops nicknames. One per line.": "Devops takma adlarının listesi. Her satıra bir tane.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/uk.json b/translations/uk.json index 9bfaeb396..6a50bea8d 100644 --- a/translations/uk.json +++ b/translations/uk.json @@ -593,5 +593,6 @@ "Credentials are too long": "Облікові дані задовгі", "Site DevOps": "Сайт DevOps", "A list of devops nicknames. One per line.": "Список ніків devops. По одному на рядок.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/yi.json b/translations/yi.json index 43588504b..fa23b0fa8 100644 --- a/translations/yi.json +++ b/translations/yi.json @@ -593,5 +593,6 @@ "Credentials are too long": "קראַדענטשאַלז זענען צו לאַנג", "Site DevOps": "וועבזייטל DevOps", "A list of devops nicknames. One per line.": "א רשימה פון דיוואָפּס ניקניימז. איינער פּער שורה.", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/translations/zh.json b/translations/zh.json index cd19651a4..dc7bedea9 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -593,5 +593,6 @@ "Credentials are too long": "凭据太长", "Site DevOps": "站点 DevOps", "A list of devops nicknames. One per line.": "devops 昵称列表。 每行一个。", - "devops": "devops" + "devops": "devops", + "Reject spam accounts", "" } diff --git a/webapp_profile.py b/webapp_profile.py index e6aeebe20..c352a61d8 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -2094,6 +2094,7 @@ def _html_edit_profile_encryption_keys(pgp_fingerprint: str, def _html_edit_profile_options(is_admin: bool, manually_approves_followers: str, + reject_spam_actors: str, is_bot: str, is_group: str, follow_dms: str, remove_twitter: str, notify_likes: str, notify_reactions: str, @@ -2106,6 +2107,9 @@ def _html_edit_profile_options(is_admin: bool, edit_profile_form += \ edit_check_box(translate['Approve follower requests'], 'approveFollowers', manually_approves_followers) + edit_profile_form += \ + edit_check_box(translate['Reject spam accounts'], + 'rejectSpamActors', reject_spam_actors) edit_profile_form += \ edit_check_box(translate['This is a bot account'], 'isBot', is_bot) @@ -2321,7 +2325,8 @@ def html_edit_profile(server, translate: {}, pgp_pub_key = enigma_pub_key = '' pgp_fingerprint = xmpp_address = matrix_address = '' ssb_address = blog_address = tox_address = '' - cwtch_address = briar_address = manually_approves_followers = '' + cwtch_address = briar_address = '' + manually_approves_followers = reject_spam_actors = '' actor_json = load_json(actor_filename) if actor_json: @@ -2354,6 +2359,11 @@ def html_edit_profile(server, translate: {}, manually_approves_followers = 'checked' else: manually_approves_followers = '' + reject_spam_actors = '' + actor_spam_filter_filename = \ + acct_dir(base_dir, nickname, domain) + '/.reject_spam_actors' + if os.path.isfile(actor_spam_filter_filename): + reject_spam_actors = 'checked' if actor_json.get('type'): if actor_json['type'] == 'Service': is_bot = 'checked' @@ -2469,6 +2479,7 @@ def html_edit_profile(server, translate: {}, # Option checkboxes edit_profile_form += \ _html_edit_profile_options(is_admin, manually_approves_followers, + reject_spam_actors, is_bot, is_group, follow_dms, remove_twitter, notify_likes, notify_reactions,