Merge branch 'main' of gitlab.com:bashrc2/epicyon

merge-requests/30/head
Bob Mottram 2022-11-09 13:29:10 +00:00
commit 0ba5dab646
47 changed files with 239 additions and 37 deletions

View File

@ -21,6 +21,7 @@ from functools import partial
from hashlib import sha256
from hashlib import md5
from shutil import copyfile
from session import site_is_verified
from session import create_session
from session import get_session_for_domain
from session import get_session_for_domains
@ -6310,6 +6311,13 @@ class PubServer(BaseHTTPRequestHandler):
set_blog_address(actor_json,
fields['blogAddress'])
actor_changed = True
site_is_verified(curr_session,
self.server.base_dir,
self.server.http_prefix,
nickname, domain,
fields['blogAddress'],
True,
self.server.debug)
else:
if current_blog_address:
set_blog_address(actor_json, '')
@ -6480,6 +6488,13 @@ class PubServer(BaseHTTPRequestHandler):
fields['websiteUrl'],
self.server.translate)
actor_changed = True
site_is_verified(curr_session,
self.server.base_dir,
self.server.http_prefix,
nickname, domain,
fields['websiteUrl'],
True,
self.server.debug)
else:
if current_website:
set_website(actor_json, '', self.server.translate)

View File

@ -35,6 +35,7 @@
--pageslist-color: #dddddd;
--pageslist-selected-color: white;
--main-fg-color: #dddddd;
--verified-site-color: lightgreen;
--cw-color: #dddddd;
--cw-style: normal;
--cw-weight: bold;
@ -1126,6 +1127,16 @@ h3 {
user-select: all;
}
.verified_site {
color: var(--verified-site-color)
}
.verified_site a:link {
color: var(--verified-site-color)
}
.verified_site a:visited {
color: var(--verified-site-color)
}
@media screen and (min-width: 400px) {
body, html {
background-color: var(--main-bg-color);

View File

@ -48,6 +48,7 @@ from session import create_session
from session import get_json
from session import get_vcard
from session import download_html
from session import verify_html
from session import download_ssml
from newswire import get_rss
from filters import add_filter
@ -373,6 +374,9 @@ def _command_options() -> None:
help='Show the SSML for a given activitypub url')
parser.add_argument('--htmlpost', dest='htmlpost', type=str, default=None,
help='Show the html for a given activitypub url')
parser.add_argument('--verifyurl', dest='verifyurl', type=str,
default=None,
help='Verify an identity using the given url')
parser.add_argument('--rss', dest='rss', type=str, default=None,
help='Show an rss feed for a given url')
parser.add_argument('-f', '--federate', nargs='+', dest='federation_list',
@ -1159,6 +1163,36 @@ def _command_options() -> None:
print(test_html)
sys.exit()
if argb.verifyurl:
if not argb.nickname:
print('You must specify a nickname for the handle ' +
'to be verified nickname@domain using the ' +
'--nickname option')
sys.exit()
profile_str = 'https://www.w3.org/ns/activitystreams'
as_header = {
'Accept': 'text/html; profile="' + profile_str + '"'
}
if not argb.domain:
argb.domain = get_config_param(base_dir, 'domain')
domain = ''
if argb.domain:
domain = argb.domain
if not domain:
print('You must specify a domain for the handle ' +
'to be verified nickname@domain using the ' +
'--domain option')
sys.exit()
session = create_session(None)
verified = \
verify_html(session, argb.verifyurl, debug, __version__,
http_prefix, argb.nickname, domain)
if verified:
print('Verified')
sys.exit()
print('Verification failed')
sys.exit()
# create cache for actors
if not os.path.isdir(base_dir + '/cache'):
os.mkdir(base_dir + '/cache')

View File

@ -9,6 +9,8 @@ __module_group__ = "Session"
import os
import requests
from utils import text_in_file
from utils import acct_dir
from utils import url_permitted
from utils import is_image_file
from httpsig import create_signed_header
@ -372,6 +374,78 @@ def download_html(signing_priv_key_pem: str,
None, quiet, debug, False)
def verify_html(session, url: str, debug: bool,
version: str, http_prefix: str, nickname: str, domain: str,
timeout_sec: int = 20, quiet: bool = False) -> bool:
"""Verify that the handle for nickname@domain exists within the
given url
"""
if not url_exists(session, url, 3, http_prefix, domain):
return False
as_header = {
'Accept': 'text/html'
}
verification_site_html = \
download_html(None, session, url,
as_header, None, debug, __version__,
http_prefix, domain, timeout_sec, quiet)
if not verification_site_html:
if debug:
print('Verification site could not be contacted ' +
url)
return False
verification_site_html = verification_site_html.decode()
actor_links = [
domain + '/@' + nickname,
domain + '/users/' + nickname
]
for actor in actor_links:
if domain.endswith('.onion') or domain.endswith('.i2p'):
actor = 'http://' + actor
else:
actor = http_prefix + '://' + actor
link_str = ' rel="me" href="' + actor + '"'
if link_str in verification_site_html:
return True
link_str = ' href="' + actor + '" rel="me"'
if link_str in verification_site_html:
return True
return False
def site_is_verified(session, base_dir: str, http_prefix: str,
nickname: str, domain: str,
url: str, update: bool, debug: bool) -> bool:
"""Is the given website verified?
"""
verified_sites_filename = \
acct_dir(base_dir, nickname, domain) + '/verified_sites.txt'
verified_file_exists = False
if os.path.isfile(verified_sites_filename):
verified_file_exists = True
if text_in_file(url + '\n', verified_sites_filename, True):
return True
if not update:
return False
verified = \
verify_html(session, url, debug,
__version__, http_prefix, nickname, domain)
if verified:
write_type = 'a+'
if not verified_file_exists:
write_type = 'w+'
try:
with open(verified_sites_filename, write_type,
encoding='utf-8') as fp_verified:
fp_verified.write(url + '\n')
except OSError:
print('EX: Verified sites could not be updated ' +
verified_sites_filename)
return verified
def download_ssml(signing_priv_key_pem: str,
session, url: str, headers: {}, params: {}, debug: bool,
version: str, http_prefix: str, domain: str,

View File

@ -1,4 +1,5 @@
{
"verified-site-color": "lightgreen",
"code-color": "white",
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
"pwa-theme-background-color": "black-translucent",

View File

@ -1,4 +1,5 @@
{
"verified-site-color": "lightgreen",
"code-color": "blue",
"diff-add": "#111",
"diff-remove": "#333",
@ -7,7 +8,7 @@
"dropdown-fg-color": "#222",
"dropdown-bg-color": "white",
"dropdown-bg-color-hover": "lightgrey",
"dropdown-fg-color-hover": "#222",
"dropdown-fg-color-hover": "#222",
"today-circle": "#03a494",
"options-main-link-color-hover": "white",
"main-link-color-hover": "blue",

View File

@ -1,6 +1,7 @@
{
{
"verified-site-color": "lightgreen",
"newswire-publish-icon": "True",
"full-width-timeline-buttons": "False",
"full-width-timeline-buttons": "False",
"icons-as-buttons": "False",
"rss-icon-at-top": "True",
"publish-button-at-top": "False",

View File

@ -1,4 +1,5 @@
{
"verified-site-color": "lightgreen",
"code-color": "lightblue",
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
"pwa-theme-background-color": "black-translucent",

View File

@ -1,4 +1,5 @@
{
"verified-site-color": "lightgreen",
"code-color": "blue",
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
"pwa-theme-background-color": "black-translucent",

View File

@ -1,4 +1,5 @@
{
"verified-site-color": "lightgreen",
"code-color": "lightblue",
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
"pwa-theme-background-color": "black-translucent",

View File

@ -1,4 +1,5 @@
{
"verified-site-color": "lightgreen",
"code-color": "blue",
"diff-add": "#111",
"diff-remove": "#333",

View File

@ -1,4 +1,5 @@
{
"verified-site-color": "white",
"code-color": "blue",
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
"pwa-theme-background-color": "black-translucent",

View File

@ -1,4 +1,5 @@
{
"verified-site-color": "lightgreen",
"diff-add": "#111",
"diff-remove": "#333",
"code-color": "blue",

View File

@ -1,4 +1,5 @@
{
"verified-site-color": "lightgreen",
"code-color": "lightblue",
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
"pwa-theme-background-color": "black-translucent",

View File

@ -1,4 +1,5 @@
{
"verified-site-color": "lightgreen",
"code-color": "blue",
"diff-add": "#111",
"diff-remove": "#333",

View File

@ -1,4 +1,5 @@
{
"verified-site-color": "lightgreen",
"code-color": "lightblue",
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
"pwa-theme-background-color": "black-translucent",

View File

@ -1,4 +1,5 @@
{
"verified-site-color": "lightgreen",
"code-color": "lightblue",
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
"pwa-theme-background-color": "black-translucent",

View File

@ -1,4 +1,5 @@
{
"verified-site-color": "lightgreen",
"code-color": "blue",
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
"pwa-theme-background-color": "black-translucent",

View File

@ -1,4 +1,5 @@
{
"verified-site-color": "lightgreen",
"code-color": "lightblue",
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
"pwa-theme-background-color": "black-translucent",

View File

@ -1,4 +1,5 @@
{
"verified-site-color": "lightgreen",
"code-color": "blue",
"font-size-header": "18px",
"font-size-header-mobile": "32px",

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "رفض حسابات البريد العشوائي",
"User Manual": "دليل الاستخدام",
"Allow announces": "تعلن السماح"
"Allow announces": "تعلن السماح",
"Send": "إرسال"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "স্প্যাম অ্যাকাউন্ট প্রত্যাখ্যান করুন",
"User Manual": "ব্যবহার বিধি",
"Allow announces": "ঘোষণার অনুমতি দিন"
"Allow announces": "ঘোষণার অনুমতি দিন",
"Send": "পাঠান"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "Rebutja els comptes de correu brossa",
"User Manual": "Manual d'usuari",
"Allow announces": "Permet anuncis"
"Allow announces": "Permet anuncis",
"Send": "Enviar"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "Gwrthod cyfrifon sbam",
"User Manual": "Llawlyfr Defnyddiwr",
"Allow announces": "Caniatáu cyhoeddiadau"
"Allow announces": "Caniatáu cyhoeddiadau",
"Send": "Anfon"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "Gwrthod cyfrifon sbam",
"User Manual": "Benutzerhandbuch",
"Allow announces": "Zulassen kündigt an"
"Allow announces": "Zulassen kündigt an",
"Send": "Senden"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "Gwrthod cyfrifon sbam",
"User Manual": "Εγχειρίδιο χρήστη",
"Allow announces": "Allow ανακοινώνει"
"Allow announces": "Allow ανακοινώνει",
"Send": "Στείλετε"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "Reject spam accounts",
"User Manual": "User Manual",
"Allow announces": "Allow announces"
"Allow announces": "Allow announces",
"Send": "Send"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "Rechazar cuentas de spam",
"User Manual": "Manual de usuario",
"Allow announces": "Permitir anuncios"
"Allow announces": "Permitir anuncios",
"Send": "Enviar"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "Rejeter les comptes de spam",
"User Manual": "Manuel de l'Utilisateur",
"Allow announces": "Autoriser les annonces"
"Allow announces": "Autoriser les annonces",
"Send": "Envoyer"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "Diúltaigh cuntais turscair",
"User Manual": "Lámhleabhar Úsáideora",
"Allow announces": "Ceadaigh fógraí"
"Allow announces": "Ceadaigh fógraí",
"Send": "Seol"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "स्पैम खातों को अस्वीकार करें",
"User Manual": "उपयोगकर्ता पुस्तिका",
"Allow announces": "घोषणा की अनुमति दें"
"Allow announces": "घोषणा की अनुमति दें",
"Send": "भेजना"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "Rifiuta gli account spam",
"User Manual": "Manuale d'uso",
"Allow announces": "Consenti annunci"
"Allow announces": "Consenti annunci",
"Send": "Inviare"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "スパムアカウントを拒否",
"User Manual": "ユーザーマニュアル",
"Allow announces": "アナウンスを許可"
"Allow announces": "アナウンスを許可",
"Send": "送信"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "스팸 계정 거부",
"User Manual": "사용자 매뉴얼",
"Allow announces": "공지 허용"
"Allow announces": "공지 허용",
"Send": "보내다"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "Hesabên spam red bikin",
"User Manual": "Manual Bikarhêner",
"Allow announces": "Destûr dide ragihandin"
"Allow announces": "Destûr dide ragihandin",
"Send": "Şandin"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "Spamaccounts afwijzen",
"User Manual": "Handleiding",
"Allow announces": "Aankondigingen toestaan"
"Allow announces": "Aankondigingen toestaan",
"Send": "Versturen"
}

View File

@ -592,5 +592,6 @@
"devops": "devops",
"Reject spam accounts": "Reject spam accounts",
"User Manual": "User Manual",
"Allow announces": "Allow announces"
"Allow announces": "Allow announces",
"Send": "Send"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "Odrzuć konta spamowe",
"User Manual": "Instrukcja obsługi",
"Allow announces": "Zezwól na ogłoszenia"
"Allow announces": "Zezwól na ogłoszenia",
"Send": "Wysłać"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "Rejeitar contas de spam",
"User Manual": "Manual do usuário",
"Allow announces": "Permitir anúncios"
"Allow announces": "Permitir anúncios",
"Send": "Mandar"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "Отклонить спам-аккаунты",
"User Manual": "Руководство пользователя",
"Allow announces": "Разрешить объявления"
"Allow announces": "Разрешить объявления",
"Send": "Отправлять"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "Kataa akaunti za barua taka",
"User Manual": "Mwongozo wa mtumiaji",
"Allow announces": "Ruhusu matangazo"
"Allow announces": "Ruhusu matangazo",
"Send": "Tuma"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "Spam hesapları reddet",
"User Manual": "Kullanım kılavuzu",
"Allow announces": "Duyurulara izin ver"
"Allow announces": "Duyurulara izin ver",
"Send": "Göndermek"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "Відхилити спам-акаунти",
"User Manual": "Посібник користувача",
"Allow announces": "Дозволити оголошення"
"Allow announces": "Дозволити оголошення",
"Send": "Надіслати"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "אָפּוואַרפן ספּאַם אַקאַונץ",
"User Manual": "באנוצער אנווייזער",
"Allow announces": "לאָזן אַנאַונסיז"
"Allow announces": "לאָזן אַנאַונסיז",
"Send": "שיקן"
}

View File

@ -596,5 +596,6 @@
"devops": "devops",
"Reject spam accounts": "拒绝垃圾邮件帐户",
"User Manual": "用户手册",
"Allow announces": "לאָזן אַנאַונסיז"
"Allow announces": "לאָזן אַנאַונסיז",
"Send": "发送"
}

View File

@ -880,7 +880,11 @@ def html_new_post(media_instance: bool, translate: {},
' <td><input type="submit" name="submitCitations" value="' + \
translate['Citations'] + '"></td>\n'
submit_text = translate['Publish']
if not path.endswith('/newdm') and \
not path.endswith('/newreport'):
submit_text = translate['Publish']
else:
submit_text = translate['Send']
if custom_submit_text:
submit_text = custom_submit_text
new_post_form += \

View File

@ -84,6 +84,7 @@ from blocking import get_cw_list_variable
from blocking import is_blocked
from content import bold_reading_string
from roles import is_devops
from session import site_is_verified
THEME_FORMATS = '.zip, .gz'
@ -712,6 +713,7 @@ def html_profile(signing_priv_key_pem: str,
tox_address = get_tox_address(profile_json)
briar_address = get_briar_address(profile_json)
cwtch_address = get_cwtch_address(profile_json)
verified_site_checkmark = ''
if donate_url or website_url or xmpp_address or matrix_address or \
ssb_address or tox_address or briar_address or \
cwtch_address or pgp_pub_key or enigma_pub_key or \
@ -724,10 +726,21 @@ def html_profile(signing_priv_key_pem: str,
'<button class="donateButton">' + translate['Donate'] + \
'</button></a></p>\n'
if website_url:
donate_section += \
'<p>' + translate['Website'] + ': <a href="' + \
website_url + '" rel="me" tabindex="1">' + \
website_url + '</a></p>\n'
if site_is_verified(session, base_dir, http_prefix,
nickname, domain,
website_url, False, debug):
donate_section += \
'<p><div class="verified_site">' + \
translate['Website'] + ': ' + \
verified_site_checkmark + '<a href="' + \
website_url + '" rel="me" tabindex="1">' + \
website_url + '</a></div></p>\n'
else:
donate_section += \
'<p>' + translate['Website'] + ': ' + \
'<a href="' + \
website_url + '" rel="me" tabindex="1">' + \
website_url + '</a></p>\n'
if gemini_link:
donate_section += \
'<p>' + 'Gemini' + ': <a href="' + \
@ -739,10 +752,20 @@ def html_profile(signing_priv_key_pem: str,
email_address + '" tabindex="1">' + \
email_address + '</a></p>\n'
if blog_address:
donate_section += \
'<p>Blog: <a href="' + \
blog_address + '" rel="me" tabindex="1">' + \
blog_address + '</a></p>\n'
if site_is_verified(session, base_dir, http_prefix,
nickname, domain,
blog_address, False, debug):
donate_section += \
'<p><div class="verified_site">' + \
'Blog: ' + verified_site_checkmark + \
'<a href="' + \
blog_address + '" rel="me" tabindex="1">' + \
blog_address + '</a></div></p>\n'
else:
donate_section += \
'<p>Blog: <a href="' + \
blog_address + '" rel="me" tabindex="1">' + \
blog_address + '</a></p>\n'
if xmpp_address:
donate_section += \
'<p>' + translate['XMPP'] + ': <a href="xmpp:' + \