Permitted DM instances within edit profile screen

main
Bob Mottram 2021-04-22 10:56:40 +01:00
parent 702fa3167f
commit 91c955006a
19 changed files with 87 additions and 22 deletions

View File

@ -5019,11 +5019,24 @@ class PubServer(BaseHTTPRequestHandler):
if os.path.isfile(blockedFilename): if os.path.isfile(blockedFilename):
os.remove(blockedFilename) os.remove(blockedFilename)
# Save DM allowed instances list.
# The allow list for incoming DMs,
# if the .followDMs flag file exists
dmAllowedInstancesFilename = \
baseDir + '/accounts/' + \
nickname + '@' + domain + '/dmAllowedinstances.txt'
if fields.get('dmAllowedInstances'):
with open(dmAllowedInstancesFilename, 'w+') as aFile:
aFile.write(fields['dmAllowedInstances'])
else:
if os.path.isfile(dmAllowedInstancesFilename):
os.remove(dmAllowedInstancesFilename)
# save allowed instances list # save allowed instances list
# This is the account level allow list
allowedInstancesFilename = \ allowedInstancesFilename = \
baseDir + '/accounts/' + \ baseDir + '/accounts/' + \
nickname + '@' + domain + \ nickname + '@' + domain + '/allowedinstances.txt'
'/allowedinstances.txt'
if fields.get('allowedInstances'): if fields.get('allowedInstances'):
with open(allowedInstancesFilename, 'w+') as aFile: with open(allowedInstancesFilename, 'w+') as aFile:
aFile.write(fields['allowedInstances']) aFile.write(fields['allowedInstances'])

View File

@ -401,5 +401,7 @@
"counselor": "مستشار", "counselor": "مستشار",
"Counselors": "المستشارين", "Counselors": "المستشارين",
"shocked": "صدمت", "shocked": "صدمت",
"Encrypted": "مشفر" "Encrypted": "مشفر",
"Direct Message permitted instances": "الرسالة المباشرة المسموح بها",
"Direct messages are always allowed from these instances.": "الرسائل المباشرة مسموح بها دائما من هذه المثيلات."
} }

View File

@ -401,5 +401,7 @@
"counselor": "conseller", "counselor": "conseller",
"Counselors": "Consellers", "Counselors": "Consellers",
"shocked": "sorprès", "shocked": "sorprès",
"Encrypted": "Xifrat" "Encrypted": "Xifrat",
"Direct Message permitted instances": "Instàncies permeses del missatge directe",
"Direct messages are always allowed from these instances.": "Els missatges directes sempre estan permesos d'aquests casos."
} }

View File

@ -401,5 +401,7 @@
"counselor": "cynghorydd", "counselor": "cynghorydd",
"Counselors": "Cynghorwyr", "Counselors": "Cynghorwyr",
"shocked": "sioc", "shocked": "sioc",
"Encrypted": "Amgryptio" "Encrypted": "Amgryptio",
"Direct Message permitted instances": "Achosion a ganiateir negeseuon uniongyrchol",
"Direct messages are always allowed from these instances.": "Caniateir negeseuon uniongyrchol bob amser o'r achosion hyn."
} }

View File

@ -401,5 +401,7 @@
"counselor": "Beraterin", "counselor": "Beraterin",
"Counselors": "Berater", "Counselors": "Berater",
"shocked": "schockiert", "shocked": "schockiert",
"Encrypted": "Verschlüsselt" "Encrypted": "Verschlüsselt",
"Direct Message permitted instances": "Direktnachricht erlaubte Instanzen",
"Direct messages are always allowed from these instances.": "Direkte Nachrichten sind in diesen Fällen immer zulässig."
} }

View File

@ -401,5 +401,7 @@
"counselor": "counselor", "counselor": "counselor",
"Counselors": "Counselors", "Counselors": "Counselors",
"shocked": "shocked", "shocked": "shocked",
"Encrypted": "Encrypted" "Encrypted": "Encrypted",
"Direct Message permitted instances": "Direct Message permitted instances",
"Direct messages are always allowed from these instances.": "Direct messages are always allowed from these instances."
} }

View File

@ -401,5 +401,7 @@
"counselor": "Consejera", "counselor": "Consejera",
"Counselors": "Consejeras", "Counselors": "Consejeras",
"shocked": "conmocionada", "shocked": "conmocionada",
"Encrypted": "Cifrada" "Encrypted": "Cifrada",
"Direct Message permitted instances": "Mensaje directo permitido instancias",
"Direct messages are always allowed from these instances.": "Los mensajes directos siempre están permitidos de estas instancias."
} }

View File

@ -401,5 +401,7 @@
"counselor": "Conseillère", "counselor": "Conseillère",
"Counselors": "Conseillères", "Counselors": "Conseillères",
"shocked": "sous le choc", "shocked": "sous le choc",
"Encrypted": "Crypté" "Encrypted": "Crypté",
"Direct Message permitted instances": "Message direct des instances autorisées",
"Direct messages are always allowed from these instances.": "Les messages directs sont toujours autorisés dans ces instances."
} }

View File

@ -401,5 +401,7 @@
"counselor": "Comhairleoir", "counselor": "Comhairleoir",
"Counselors": "Comhairleoirí", "Counselors": "Comhairleoirí",
"shocked": "ionadh", "shocked": "ionadh",
"Encrypted": "Criptithe" "Encrypted": "Criptithe",
"Direct Message permitted instances": "Ceadaíonn teachtaireacht dhíreach cásanna",
"Direct messages are always allowed from these instances.": "Ceadaítear teachtaireachtaí díreacha i gcónaí ó na cásanna seo."
} }

View File

@ -401,5 +401,7 @@
"counselor": "काउंसलर", "counselor": "काउंसलर",
"Counselors": "सलाहकार", "Counselors": "सलाहकार",
"shocked": "हैरान", "shocked": "हैरान",
"Encrypted": "को गोपित" "Encrypted": "को गोपित",
"Direct Message permitted instances": "प्रत्यक्ष संदेश अनुमत उदाहरण",
"Direct messages are always allowed from these instances.": "इन उदाहरणों से प्रत्यक्ष संदेश हमेशा अनुमति देते हैं।"
} }

View File

@ -401,5 +401,7 @@
"counselor": "Consulente", "counselor": "Consulente",
"Counselors": "Consiglieri", "Counselors": "Consiglieri",
"shocked": "scioccata", "shocked": "scioccata",
"Encrypted": "Crittografato" "Encrypted": "Crittografato",
"Direct Message permitted instances": "Messaggio diretto istanze consentite",
"Direct messages are always allowed from these instances.": "I messaggi diretti sono sempre ammessi da questi casi."
} }

View File

@ -401,5 +401,7 @@
"counselor": "カウンセラー", "counselor": "カウンセラー",
"Counselors": "カウンセラー", "Counselors": "カウンセラー",
"shocked": "ショックを受けた", "shocked": "ショックを受けた",
"Encrypted": "暗号化" "Encrypted": "暗号化",
"Direct Message permitted instances": "直接メッセージ許可インスタンス",
"Direct messages are always allowed from these instances.": "直接メッセージは常にこれらのインスタンスから許可されています。"
} }

View File

@ -401,5 +401,7 @@
"counselor": "Pêşnîyarvan", "counselor": "Pêşnîyarvan",
"Counselors": "Selêwirmendan", "Counselors": "Selêwirmendan",
"shocked": "şok kirin", "shocked": "şok kirin",
"Encrypted": "Encîfre kirin" "Encrypted": "Encîfre kirin",
"Direct Message permitted instances": "Peyama rasterast destûrê",
"Direct messages are always allowed from these instances.": "Peyamên rasterast her gav ji van deman têne destûr kirin."
} }

View File

@ -397,5 +397,7 @@
"counselor": "Counselors", "counselor": "Counselors",
"Counselors": "Counselors", "Counselors": "Counselors",
"shocked": "shocked", "shocked": "shocked",
"Encrypted": "Encrypted" "Encrypted": "Encrypted",
"Direct Message permitted instances": "Direct Message permitted instances",
"Direct messages are always allowed from these instances.": "Direct messages are always allowed from these instances."
} }

View File

@ -401,5 +401,7 @@
"counselor": "Conselheira", "counselor": "Conselheira",
"Counselors": "Conselheiras", "Counselors": "Conselheiras",
"shocked": "chocada", "shocked": "chocada",
"Encrypted": "Criptografada" "Encrypted": "Criptografada",
"Direct Message permitted instances": "Mensagens diretas permitidas instâncias",
"Direct messages are always allowed from these instances.": "Mensagens diretas são sempre permitidas a partir dessas instâncias."
} }

View File

@ -401,5 +401,7 @@
"counselor": "Советник", "counselor": "Советник",
"Counselors": "Советники", "Counselors": "Советники",
"shocked": "потрясенный", "shocked": "потрясенный",
"Encrypted": "Зашифрованный" "Encrypted": "Зашифрованный",
"Direct Message permitted instances": "Прямое сообщение разрешено экземпляры",
"Direct messages are always allowed from these instances.": "Прямые сообщения всегда допускаются из этих экземпляров."
} }

View File

@ -401,5 +401,7 @@
"counselor": "顾问", "counselor": "顾问",
"Counselors": "辅导员", "Counselors": "辅导员",
"shocked": "震惊的", "shocked": "震惊的",
"Encrypted": "加密的" "Encrypted": "加密的",
"Direct Message permitted instances": "直接留言允许实例",
"Direct messages are always allowed from these instances.": "这些实例始终允许直接消息。"
} }

View File

@ -2214,11 +2214,11 @@ def dmAllowedFromDomain(baseDir: str,
i.e. Mostly you only want DMs from followers, but there are i.e. Mostly you only want DMs from followers, but there are
a few particular instances that you trust a few particular instances that you trust
""" """
dmAllowedDomainsFilename = \ dmAllowedInstancesFilename = \
baseDir + '/accounts/' + \ baseDir + '/accounts/' + \
nickname + '@' + domain + '/dmAllowedDomains.txt' nickname + '@' + domain + '/dmAllowedInstances.txt'
if not os.path.isfile(dmAllowedDomainsFilename): if not os.path.isfile(dmAllowedInstancesFilename):
return False return False
if sendingActorDomain + '\n' in open(dmAllowedDomainsFilename).read(): if sendingActorDomain + '\n' in open(dmAllowedInstancesFilename).read():
return True return True
return False return False

View File

@ -1184,6 +1184,14 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
with open(blockedFilename, 'r') as blockedfile: with open(blockedFilename, 'r') as blockedfile:
blockedStr = blockedfile.read() blockedStr = blockedfile.read()
dmAllowedInstancesStr = ''
dmAllowedInstancesFilename = \
baseDir + '/accounts/' + \
nickname + '@' + domain + '/dmAllowedInstances.txt'
if os.path.isfile(dmAllowedInstancesFilename):
with open(dmAllowedInstancesFilename, 'r') as dmAllowedInstancesFile:
dmAllowedInstancesStr = dmAllowedInstancesFile.read()
allowedInstancesStr = '' allowedInstancesStr = ''
allowedInstancesFilename = \ allowedInstancesFilename = \
baseDir + '/accounts/' + \ baseDir + '/accounts/' + \
@ -1740,6 +1748,18 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
' <textarea id="message" name="blocked" style="height:200px" ' + \ ' <textarea id="message" name="blocked" style="height:200px" ' + \
'spellcheck="false">' + blockedStr + '</textarea>\n' 'spellcheck="false">' + blockedStr + '</textarea>\n'
editProfileForm += \
' <br><b><label class="labels">' + \
translate['Direct Message permitted instances'] + '</label></b>\n'
idx = 'Direct messages are always allowed from these instances.'
editProfileForm += \
' <br><label class="labels">' + \
translate[idx] + '</label>\n'
editProfileForm += \
' <textarea id="message" name="dmAllowedInstances" ' + \
'style="height:200px" spellcheck="false">' + \
dmAllowedInstancesStr + '</textarea>\n'
editProfileForm += \ editProfileForm += \
' <br><b><label class="labels">' + \ ' <br><b><label class="labels">' + \
translate['Federation list'] + '</label></b>\n' translate['Federation list'] + '</label></b>\n'