mirror of https://gitlab.com/bashrc2/epicyon
Optionally supply a reason when using the block button
parent
8b144d3bb9
commit
beb9f8a033
74
blocking.py
74
blocking.py
|
@ -327,8 +327,73 @@ def add_global_block(base_dir: str,
|
|||
return True
|
||||
|
||||
|
||||
def _add_block_reason(base_dir: str,
|
||||
nickname: str, domain: str,
|
||||
block_nickname: str, block_domain: str,
|
||||
reason: str) -> bool:
|
||||
"""Store a block reason
|
||||
"""
|
||||
if not reason:
|
||||
return False
|
||||
|
||||
domain = remove_domain_port(domain)
|
||||
blocking_reasons_filename = \
|
||||
acct_dir(base_dir, nickname, domain) + '/blocking.txt'
|
||||
|
||||
if not block_nickname.startswith('#'):
|
||||
# is the handle already blocked?
|
||||
block_id = block_nickname + '@' + block_domain
|
||||
else:
|
||||
block_id = block_nickname
|
||||
|
||||
reason = reason.replace('\n', '').strip()
|
||||
reason_line = block_id + ' ' + reason + '\n'
|
||||
|
||||
if os.path.isfile(blocking_reasons_filename):
|
||||
if not text_in_file(block_id,
|
||||
blocking_reasons_filename):
|
||||
try:
|
||||
with open(blocking_reasons_filename, 'a+',
|
||||
encoding='utf-8') as reas_file:
|
||||
reas_file.write(reason_line)
|
||||
except OSError:
|
||||
print('EX: unable to add blocking reason 2 ' +
|
||||
block_id)
|
||||
else:
|
||||
reasons_str = ''
|
||||
try:
|
||||
with open(blocking_reasons_filename, 'r',
|
||||
encoding='utf-8') as reas_file:
|
||||
reasons_str = reas_file.read()
|
||||
except OSError:
|
||||
print('EX: unable to read blocking reasons 2')
|
||||
reasons_lines = reasons_str.split('\n')
|
||||
new_reasons_str = ''
|
||||
for line in reasons_lines:
|
||||
if not line.startswith(block_id + ' '):
|
||||
new_reasons_str += line + '\n'
|
||||
continue
|
||||
new_reasons_str += reason_line
|
||||
try:
|
||||
with open(blocking_reasons_filename, 'w+',
|
||||
encoding='utf-8') as reas_file:
|
||||
reas_file.write(new_reasons_str)
|
||||
except OSError:
|
||||
print('EX: unable to save blocking reasons 2' +
|
||||
blocking_reasons_filename)
|
||||
else:
|
||||
try:
|
||||
with open(blocking_reasons_filename, 'w+',
|
||||
encoding='utf-8') as reas_file:
|
||||
reas_file.write(reason_line)
|
||||
except OSError:
|
||||
print('EX: unable to save blocking reason 2 ' +
|
||||
block_id + ' ' + blocking_reasons_filename)
|
||||
|
||||
|
||||
def add_block(base_dir: str, nickname: str, domain: str,
|
||||
block_nickname: str, block_domain: str) -> bool:
|
||||
block_nickname: str, block_domain: str,
|
||||
reason: str) -> bool:
|
||||
"""Block the given account
|
||||
"""
|
||||
if block_domain.startswith(domain) and nickname == block_nickname:
|
||||
|
@ -398,6 +463,11 @@ def add_block(base_dir: str, nickname: str, domain: str,
|
|||
except OSError:
|
||||
print('EX: unable to append block handle ' + block_handle)
|
||||
return False
|
||||
|
||||
if reason:
|
||||
_add_block_reason(base_dir, nickname, domain,
|
||||
block_nickname, block_domain, reason)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
@ -956,7 +1026,7 @@ def outbox_block(base_dir: str, nickname: str, domain: str,
|
|||
domain_blocked_full = get_full_domain(domain_blocked, port_blocked)
|
||||
|
||||
add_block(base_dir, nickname, domain,
|
||||
nickname_blocked, domain_blocked_full)
|
||||
nickname_blocked, domain_blocked_full, '')
|
||||
|
||||
if debug:
|
||||
print('DEBUG: post blocked via c2s - ' + post_filename)
|
||||
|
|
|
@ -4291,9 +4291,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
return
|
||||
|
||||
if '&submitYes=' in block_confirm_params:
|
||||
blocking_actor = \
|
||||
blocking_confirm_str = \
|
||||
urllib.parse.unquote_plus(block_confirm_params)
|
||||
blocking_actor = blocking_actor.split('actor=')[1]
|
||||
block_reason = blocking_confirm_str.split('blockReason=')[1]
|
||||
if '&' in block_reason:
|
||||
block_reason = block_reason.split('&')[0]
|
||||
blocking_actor = blocking_confirm_str.split('actor=')[1]
|
||||
if '&' in blocking_actor:
|
||||
blocking_actor = blocking_actor.split('&')[0]
|
||||
blocking_nickname = get_nickname_from_actor(blocking_actor)
|
||||
|
@ -4322,7 +4325,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
' of ' + blocking_actor)
|
||||
add_block(base_dir, blocker_nickname,
|
||||
domain, blocking_nickname,
|
||||
blocking_domain_full)
|
||||
blocking_domain_full, block_reason)
|
||||
remove_follower(base_dir, blocker_nickname,
|
||||
domain,
|
||||
blocking_nickname,
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "علامات التجزئة المميزة",
|
||||
"Proxy": "الوكيل",
|
||||
"Only allow replies from followers": "السماح فقط بالردود من المتابعين",
|
||||
"Only allow replies from mutuals": "السماح فقط بالردود من المتبادلين"
|
||||
"Only allow replies from mutuals": "السماح فقط بالردود من المتبادلين",
|
||||
"Reason": "سبب"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "বৈশিষ্ট্যযুক্ত হ্যাশট্যাগ",
|
||||
"Proxy": "প্রক্সি",
|
||||
"Only allow replies from followers": "শুধুমাত্র অনুসরণকারীদের কাছ থেকে উত্তরের অনুমতি দিন",
|
||||
"Only allow replies from mutuals": "শুধুমাত্র মিউচুয়াল থেকে উত্তরের অনুমতি দিন"
|
||||
"Only allow replies from mutuals": "শুধুমাত্র মিউচুয়াল থেকে উত্তরের অনুমতি দিন",
|
||||
"Reason": "কারণ"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "Hashtags destacats",
|
||||
"Proxy": "Proxy",
|
||||
"Only allow replies from followers": "Només permet respostes dels seguidors",
|
||||
"Only allow replies from mutuals": "Només permet respostes de mútues"
|
||||
"Only allow replies from mutuals": "Només permet respostes de mútues",
|
||||
"Reason": "Raó"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "Hashtags dan sylw",
|
||||
"Proxy": "Dirprwy",
|
||||
"Only allow replies from followers": "Caniatewch atebion gan ddilynwyr yn unig",
|
||||
"Only allow replies from mutuals": "Caniatewch atebion gan gwmnïau cydfuddiannol yn unig"
|
||||
"Only allow replies from mutuals": "Caniatewch atebion gan gwmnïau cydfuddiannol yn unig",
|
||||
"Reason": "Rheswm"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "Ausgewählte Hashtags",
|
||||
"Proxy": "Stellvertreterin",
|
||||
"Only allow replies from followers": "Erlauben Sie nur Antworten von Followern",
|
||||
"Only allow replies from mutuals": "Erlauben Sie nur Antworten von Gegenseitigkeitsgesellschaften"
|
||||
"Only allow replies from mutuals": "Erlauben Sie nur Antworten von Gegenseitigkeitsgesellschaften",
|
||||
"Reason": "Grund"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "Επιλεγμένα hashtag",
|
||||
"Proxy": "Πληρεξούσιο",
|
||||
"Only allow replies from followers": "Επιτρέπονται μόνο οι απαντήσεις από τους ακόλουθους",
|
||||
"Only allow replies from mutuals": "Επιτρέπονται μόνο απαντήσεις από αμοιβαία μέλη"
|
||||
"Only allow replies from mutuals": "Επιτρέπονται μόνο απαντήσεις από αμοιβαία μέλη",
|
||||
"Reason": "Λόγος"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "Featured hashtags",
|
||||
"Proxy": "Proxy",
|
||||
"Only allow replies from followers": "Only allow replies from followers",
|
||||
"Only allow replies from mutuals": "Only allow replies from mutuals"
|
||||
"Only allow replies from mutuals": "Only allow replies from mutuals",
|
||||
"Reason": "Reason"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "Hashtags destacados",
|
||||
"Proxy": "Apoderada",
|
||||
"Only allow replies from followers": "Permitir solo respuestas de seguidores",
|
||||
"Only allow replies from mutuals": "Permitir solo respuestas de mutuas"
|
||||
"Only allow replies from mutuals": "Permitir solo respuestas de mutuas",
|
||||
"Reason": "Razón"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "هشتگ های ویژه",
|
||||
"Proxy": "پروکسی",
|
||||
"Only allow replies from followers": "فقط اجازه پاسخ از طرفداران را بدهید",
|
||||
"Only allow replies from mutuals": "فقط اجازه پاسخ از طرف متقابل را بدهید"
|
||||
"Only allow replies from mutuals": "فقط اجازه پاسخ از طرف متقابل را بدهید",
|
||||
"Reason": "دلیل"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"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 mutuals": "Autoriser uniquement les réponses des mutuelles"
|
||||
"Only allow replies from mutuals": "Autoriser uniquement les réponses des mutuelles",
|
||||
"Reason": "Raison"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "Hashtags faoi thrácht",
|
||||
"Proxy": "Seachfhreastalaí",
|
||||
"Only allow replies from followers": "Ná ceadaigh ach freagraí ó leantóirí",
|
||||
"Only allow replies from mutuals": "Ná ceadaigh ach freagraí ó chomhlachtaí frithpháirteacha"
|
||||
"Only allow replies from mutuals": "Ná ceadaigh ach freagraí ó chomhlachtaí frithpháirteacha",
|
||||
"Reason": "Cúis"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "विशेष रुप से प्रदर्शित हैशटैग",
|
||||
"Proxy": "प्रतिनिधि",
|
||||
"Only allow replies from followers": "केवल अनुयायियों के उत्तरों की अनुमति दें",
|
||||
"Only allow replies from mutuals": "केवल पारस्परिक उत्तरों की अनुमति दें"
|
||||
"Only allow replies from mutuals": "केवल पारस्परिक उत्तरों की अनुमति दें",
|
||||
"Reason": "कारण"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "Hashtag in primo piano",
|
||||
"Proxy": "Delega",
|
||||
"Only allow replies from followers": "Consenti solo risposte dai follower",
|
||||
"Only allow replies from mutuals": "Consenti solo risposte da mutue"
|
||||
"Only allow replies from mutuals": "Consenti solo risposte da mutue",
|
||||
"Reason": "Motivo"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "注目のハッシュタグ",
|
||||
"Proxy": "プロキシー",
|
||||
"Only allow replies from followers": "フォロワーからの返信のみを許可する",
|
||||
"Only allow replies from mutuals": "相互からの返信のみを許可する"
|
||||
"Only allow replies from mutuals": "相互からの返信のみを許可する",
|
||||
"Reason": "理由"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "추천 해시태그",
|
||||
"Proxy": "대리",
|
||||
"Only allow replies from followers": "팔로어의 답글만 허용",
|
||||
"Only allow replies from mutuals": "상호 간의 답장만 허용"
|
||||
"Only allow replies from mutuals": "상호 간의 답장만 허용",
|
||||
"Reason": "이유"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "Hashtagên taybetmendî",
|
||||
"Proxy": "Proxy",
|
||||
"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"
|
||||
"Only allow replies from mutuals": "Tenê destûr bidin bersivên ji hevdu",
|
||||
"Reason": "Semed"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "Aanbevolen hashtags",
|
||||
"Proxy": "Volmacht",
|
||||
"Only allow replies from followers": "Sta alleen reacties van volgers toe",
|
||||
"Only allow replies from mutuals": "Sta alleen reacties van onderlinge maatschappijen toe"
|
||||
"Only allow replies from mutuals": "Sta alleen reacties van onderlinge maatschappijen toe",
|
||||
"Reason": "Reden"
|
||||
}
|
||||
|
|
|
@ -621,5 +621,6 @@
|
|||
"Featured hashtags": "Featured hashtags",
|
||||
"Proxy": "Proxy",
|
||||
"Only allow replies from followers": "Only allow replies from followers",
|
||||
"Only allow replies from mutuals": "Only allow replies from mutuals"
|
||||
"Only allow replies from mutuals": "Only allow replies from mutuals",
|
||||
"Reason": "Reason"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "Polecane hashtagi",
|
||||
"Proxy": "Pełnomocnik",
|
||||
"Only allow replies from followers": "Zezwalaj tylko na odpowiedzi od obserwujących",
|
||||
"Only allow replies from mutuals": "Zezwalaj tylko na odpowiedzi od towarzystw wzajemnych"
|
||||
"Only allow replies from mutuals": "Zezwalaj tylko na odpowiedzi od towarzystw wzajemnych",
|
||||
"Reason": "Powód"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "Hashtags em destaque",
|
||||
"Proxy": "Proxy",
|
||||
"Only allow replies from followers": "Permitir apenas respostas de seguidores",
|
||||
"Only allow replies from mutuals": "Permitir apenas respostas de mútuos"
|
||||
"Only allow replies from mutuals": "Permitir apenas respostas de mútuos",
|
||||
"Reason": "Razão"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "Избранные хэштеги",
|
||||
"Proxy": "Прокси",
|
||||
"Only allow replies from followers": "Разрешить ответы только от подписчиков",
|
||||
"Only allow replies from mutuals": "Разрешить ответы только от взаимных"
|
||||
"Only allow replies from mutuals": "Разрешить ответы только от взаимных",
|
||||
"Reason": "Причина"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "Reli zilizoangaziwa",
|
||||
"Proxy": "Wakala",
|
||||
"Only allow replies from followers": "Ruhusu tu majibu kutoka kwa wafuasi",
|
||||
"Only allow replies from mutuals": "Ruhusu tu majibu kutoka kwa pande zote mbili"
|
||||
"Only allow replies from mutuals": "Ruhusu tu majibu kutoka kwa pande zote mbili",
|
||||
"Reason": "Sababu"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"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 mutuals": "Yalnızca ortaklardan gelen yanıtlara izin ver"
|
||||
"Only allow replies from mutuals": "Yalnızca ortaklardan gelen yanıtlara izin ver",
|
||||
"Reason": "Sebep"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "Рекомендовані хештеги",
|
||||
"Proxy": "Проксі",
|
||||
"Only allow replies from followers": "Дозволити відповіді лише від підписників",
|
||||
"Only allow replies from mutuals": "Дозволити відповіді лише від взаємних клієнтів"
|
||||
"Only allow replies from mutuals": "Дозволити відповіді лише від взаємних клієнтів",
|
||||
"Reason": "Причина"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "פֿעיִקייטן פון hashtags",
|
||||
"Proxy": "פראקסי",
|
||||
"Only allow replies from followers": "נאָר לאָזן ענטפֿערס פון אנהענגערס",
|
||||
"Only allow replies from mutuals": "לאָזן בלויז ענטפֿערס פון מיוטשואַלז"
|
||||
"Only allow replies from mutuals": "לאָזן בלויז ענטפֿערס פון מיוטשואַלז",
|
||||
"Reason": "סיבה"
|
||||
}
|
||||
|
|
|
@ -625,5 +625,6 @@
|
|||
"Featured hashtags": "特色标签",
|
||||
"Proxy": "代理人",
|
||||
"Only allow replies from followers": "只允许关注者回复",
|
||||
"Only allow replies from mutuals": "只允许来自相互的回复"
|
||||
"Only allow replies from mutuals": "只允许来自相互的回复",
|
||||
"Reason": "原因"
|
||||
}
|
||||
|
|
|
@ -385,7 +385,13 @@ def html_confirm_block(translate: {}, base_dir: str,
|
|||
translate['Yes'] + '</button>\n'
|
||||
block_str += \
|
||||
' <a href="' + origin_path_str + '"><button class="button">' + \
|
||||
translate['No'] + '</button></a>\n'
|
||||
translate['No'] + '</button></a><br>\n'
|
||||
block_str += \
|
||||
' <b><label class="labels">' + \
|
||||
translate['Reason'] + '</label></b>\n' + \
|
||||
' <textarea id="message" ' + \
|
||||
'name="blockReason" style="height:200px" spellcheck="false">' + \
|
||||
'</textarea>\n'
|
||||
block_str += ' </form>\n'
|
||||
block_str += '</center>\n'
|
||||
block_str += '</div>\n'
|
||||
|
|
Loading…
Reference in New Issue