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):
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
# This is the account level allow list
allowedInstancesFilename = \
baseDir + '/accounts/' + \
nickname + '@' + domain + \
'/allowedinstances.txt'
nickname + '@' + domain + '/allowedinstances.txt'
if fields.get('allowedInstances'):
with open(allowedInstancesFilename, 'w+') as aFile:
aFile.write(fields['allowedInstances'])

View File

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

View File

@ -401,5 +401,7 @@
"counselor": "conseller",
"Counselors": "Consellers",
"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",
"Counselors": "Cynghorwyr",
"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",
"Counselors": "Berater",
"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",
"Counselors": "Counselors",
"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",
"Counselors": "Consejeras",
"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",
"Counselors": "Conseillères",
"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",
"Counselors": "Comhairleoirí",
"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": "काउंसलर",
"Counselors": "सलाहकार",
"shocked": "हैरान",
"Encrypted": "को गोपित"
"Encrypted": "को गोपित",
"Direct Message permitted instances": "प्रत्यक्ष संदेश अनुमत उदाहरण",
"Direct messages are always allowed from these instances.": "इन उदाहरणों से प्रत्यक्ष संदेश हमेशा अनुमति देते हैं।"
}

View File

@ -401,5 +401,7 @@
"counselor": "Consulente",
"Counselors": "Consiglieri",
"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": "カウンセラー",
"Counselors": "カウンセラー",
"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",
"Counselors": "Selêwirmendan",
"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",
"Counselors": "Counselors",
"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",
"Counselors": "Conselheiras",
"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": "Советник",
"Counselors": "Советники",
"shocked": "потрясенный",
"Encrypted": "Зашифрованный"
"Encrypted": "Зашифрованный",
"Direct Message permitted instances": "Прямое сообщение разрешено экземпляры",
"Direct messages are always allowed from these instances.": "Прямые сообщения всегда допускаются из этих экземпляров."
}

View File

@ -401,5 +401,7 @@
"counselor": "顾问",
"Counselors": "辅导员",
"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
a few particular instances that you trust
"""
dmAllowedDomainsFilename = \
dmAllowedInstancesFilename = \
baseDir + '/accounts/' + \
nickname + '@' + domain + '/dmAllowedDomains.txt'
if not os.path.isfile(dmAllowedDomainsFilename):
nickname + '@' + domain + '/dmAllowedInstances.txt'
if not os.path.isfile(dmAllowedInstancesFilename):
return False
if sendingActorDomain + '\n' in open(dmAllowedDomainsFilename).read():
if sendingActorDomain + '\n' in open(dmAllowedInstancesFilename).read():
return True
return False

View File

@ -1184,6 +1184,14 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
with open(blockedFilename, 'r') as blockedfile:
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 = ''
allowedInstancesFilename = \
baseDir + '/accounts/' + \
@ -1740,6 +1748,18 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
' <textarea id="message" name="blocked" style="height:200px" ' + \
'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 += \
' <br><b><label class="labels">' + \
translate['Federation list'] + '</label></b>\n'