mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
114e6c7bf4
commit
34e533f289
85
daemon.py
85
daemon.py
|
@ -24,13 +24,13 @@ from shutil import copyfile
|
||||||
from session import create_session
|
from session import create_session
|
||||||
from webfinger import webfinger_meta
|
from webfinger import webfinger_meta
|
||||||
from webfinger import webfinger_node_info
|
from webfinger import webfinger_node_info
|
||||||
from webfinger import webfingerLookup
|
from webfinger import webfinger_lookup
|
||||||
from webfinger import webfingerUpdate
|
from webfinger import webfinger_update
|
||||||
from mastoapiv1 import mastoApiV1Response
|
from mastoapiv1 import masto_api_v1_response
|
||||||
from metadata import metaDataNodeInfo
|
from metadata import meta_data_node_info
|
||||||
from metadata import metadataCustomEmoji
|
from metadata import metadata_custom_emoji
|
||||||
from enigma import getEnigmaPubKey
|
from enigma import get_enigma_pub_key
|
||||||
from enigma import setEnigmaPubKey
|
from enigma import set_enigma_pub_key
|
||||||
from pgp import getEmailAddress
|
from pgp import getEmailAddress
|
||||||
from pgp import setEmailAddress
|
from pgp import setEmailAddress
|
||||||
from pgp import getPGPpubKey
|
from pgp import getPGPpubKey
|
||||||
|
@ -1062,23 +1062,24 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self._update_known_crawlers(uaStr)
|
self._update_known_crawlers(uaStr)
|
||||||
|
|
||||||
broch_mode = broch_modeIsActive(base_dir)
|
broch_mode = broch_modeIsActive(base_dir)
|
||||||
sendJson, sendJsonStr = mastoApiV1Response(path,
|
sendJson, sendJsonStr = \
|
||||||
calling_domain,
|
masto_api_v1_response(path,
|
||||||
uaStr,
|
calling_domain,
|
||||||
authorized,
|
uaStr,
|
||||||
http_prefix,
|
authorized,
|
||||||
base_dir,
|
http_prefix,
|
||||||
nickname, domain,
|
base_dir,
|
||||||
domain_full,
|
nickname, domain,
|
||||||
onion_domain,
|
domain_full,
|
||||||
i2p_domain,
|
onion_domain,
|
||||||
translate,
|
i2p_domain,
|
||||||
registration,
|
translate,
|
||||||
system_language,
|
registration,
|
||||||
project_version,
|
system_language,
|
||||||
customEmoji,
|
project_version,
|
||||||
show_node_info_accounts,
|
customEmoji,
|
||||||
broch_mode)
|
show_node_info_accounts,
|
||||||
|
broch_mode)
|
||||||
|
|
||||||
if sendJson is not None:
|
if sendJson is not None:
|
||||||
msg = json.dumps(sendJson).encode('utf-8')
|
msg = json.dumps(sendJson).encode('utf-8')
|
||||||
|
@ -1146,11 +1147,11 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
instanceUrl = self._get_instance_url(calling_domain)
|
instanceUrl = self._get_instance_url(calling_domain)
|
||||||
aboutUrl = instanceUrl + '/about'
|
aboutUrl = instanceUrl + '/about'
|
||||||
termsOfServiceUrl = instanceUrl + '/terms'
|
termsOfServiceUrl = instanceUrl + '/terms'
|
||||||
info = metaDataNodeInfo(self.server.base_dir,
|
info = meta_data_node_info(self.server.base_dir,
|
||||||
aboutUrl, termsOfServiceUrl,
|
aboutUrl, termsOfServiceUrl,
|
||||||
self.server.registration,
|
self.server.registration,
|
||||||
nodeInfoVersion,
|
nodeInfoVersion,
|
||||||
show_node_info_accounts)
|
show_node_info_accounts)
|
||||||
if info:
|
if info:
|
||||||
msg = json.dumps(info).encode('utf-8')
|
msg = json.dumps(info).encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
|
@ -1243,9 +1244,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
print('DEBUG: WEBFINGER lookup ' + self.path + ' ' +
|
print('DEBUG: WEBFINGER lookup ' + self.path + ' ' +
|
||||||
str(self.server.base_dir))
|
str(self.server.base_dir))
|
||||||
wfResult = \
|
wfResult = \
|
||||||
webfingerLookup(self.path, self.server.base_dir,
|
webfinger_lookup(self.path, self.server.base_dir,
|
||||||
self.server.domain, self.server.onion_domain,
|
self.server.domain, self.server.onion_domain,
|
||||||
self.server.port, self.server.debug)
|
self.server.port, self.server.debug)
|
||||||
if wfResult:
|
if wfResult:
|
||||||
msg = json.dumps(wfResult).encode('utf-8')
|
msg = json.dumps(wfResult).encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
|
@ -5382,15 +5383,15 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# change Enigma public key
|
# change Enigma public key
|
||||||
currentEnigmaPubKey = getEnigmaPubKey(actor_json)
|
currentEnigmaPubKey = get_enigma_pub_key(actor_json)
|
||||||
if fields.get('enigmapubkey'):
|
if fields.get('enigmapubkey'):
|
||||||
if fields['enigmapubkey'] != currentEnigmaPubKey:
|
if fields['enigmapubkey'] != currentEnigmaPubKey:
|
||||||
setEnigmaPubKey(actor_json,
|
set_enigma_pub_key(actor_json,
|
||||||
fields['enigmapubkey'])
|
fields['enigmapubkey'])
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
if currentEnigmaPubKey:
|
if currentEnigmaPubKey:
|
||||||
setEnigmaPubKey(actor_json, '')
|
set_enigma_pub_key(actor_json, '')
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
# change PGP public key
|
# change PGP public key
|
||||||
|
@ -6488,10 +6489,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
addActorUpdateTimestamp(actor_json)
|
addActorUpdateTimestamp(actor_json)
|
||||||
# save the actor
|
# save the actor
|
||||||
save_json(actor_json, actorFilename)
|
save_json(actor_json, actorFilename)
|
||||||
webfingerUpdate(base_dir,
|
webfinger_update(base_dir,
|
||||||
nickname, domain,
|
nickname, domain,
|
||||||
onion_domain,
|
onion_domain,
|
||||||
self.server.cached_webfingers)
|
self.server.cached_webfingers)
|
||||||
# also copy to the actors cache and
|
# also copy to the actors cache and
|
||||||
# person_cache in memory
|
# person_cache in memory
|
||||||
storePersonInCache(base_dir,
|
storePersonInCache(base_dir,
|
||||||
|
@ -7121,7 +7122,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
jamiAddress = getJamiAddress(actor_json)
|
jamiAddress = getJamiAddress(actor_json)
|
||||||
cwtchAddress = getCwtchAddress(actor_json)
|
cwtchAddress = getCwtchAddress(actor_json)
|
||||||
emailAddress = getEmailAddress(actor_json)
|
emailAddress = getEmailAddress(actor_json)
|
||||||
EnigmaPubKey = getEnigmaPubKey(actor_json)
|
EnigmaPubKey = get_enigma_pub_key(actor_json)
|
||||||
PGPpubKey = getPGPpubKey(actor_json)
|
PGPpubKey = getPGPpubKey(actor_json)
|
||||||
PGPfingerprint = getPGPfingerprint(actor_json)
|
PGPfingerprint = getPGPfingerprint(actor_json)
|
||||||
if actor_json.get('alsoKnownAs'):
|
if actor_json.get('alsoKnownAs'):
|
||||||
|
@ -18795,7 +18796,7 @@ def runDaemon(content_license_url: str,
|
||||||
|
|
||||||
# get the list of custom emoji, for use by the mastodon api
|
# get the list of custom emoji, for use by the mastodon api
|
||||||
httpd.customEmoji = \
|
httpd.customEmoji = \
|
||||||
metadataCustomEmoji(base_dir, http_prefix, httpd.domain_full)
|
metadata_custom_emoji(base_dir, http_prefix, httpd.domain_full)
|
||||||
|
|
||||||
# whether to enable broch mode, which locks down the instance
|
# whether to enable broch mode, which locks down the instance
|
||||||
setBrochMode(base_dir, httpd.domain_full, broch_mode)
|
setBrochMode(base_dir, httpd.domain_full, broch_mode)
|
||||||
|
|
|
@ -8,7 +8,7 @@ __status__ = "Production"
|
||||||
__module_group__ = "Profile Metadata"
|
__module_group__ = "Profile Metadata"
|
||||||
|
|
||||||
|
|
||||||
def getEnigmaPubKey(actor_json: {}) -> str:
|
def get_enigma_pub_key(actor_json: {}) -> str:
|
||||||
"""Returns Enigma public key for the given actor
|
"""Returns Enigma public key for the given actor
|
||||||
"""
|
"""
|
||||||
if not actor_json.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
|
@ -28,7 +28,7 @@ def getEnigmaPubKey(actor_json: {}) -> str:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def setEnigmaPubKey(actor_json: {}, enigmaPubKey: str) -> None:
|
def set_enigma_pub_key(actor_json: {}, enigmaPubKey: str) -> None:
|
||||||
"""Sets a Enigma public key for the given actor
|
"""Sets a Enigma public key for the given actor
|
||||||
"""
|
"""
|
||||||
removeKey = False
|
removeKey = False
|
||||||
|
|
|
@ -81,20 +81,20 @@ def _getMastoApiV1Account(base_dir: str, nickname: str, domain: str) -> {}:
|
||||||
return mastoAccountJson
|
return mastoAccountJson
|
||||||
|
|
||||||
|
|
||||||
def mastoApiV1Response(path: str, calling_domain: str,
|
def masto_api_v1_response(path: str, calling_domain: str,
|
||||||
uaStr: str,
|
uaStr: str,
|
||||||
authorized: bool,
|
authorized: bool,
|
||||||
http_prefix: str,
|
http_prefix: str,
|
||||||
base_dir: str, nickname: str, domain: str,
|
base_dir: str, nickname: str, domain: str,
|
||||||
domain_full: str,
|
domain_full: str,
|
||||||
onion_domain: str, i2p_domain: str,
|
onion_domain: str, i2p_domain: str,
|
||||||
translate: {},
|
translate: {},
|
||||||
registration: bool,
|
registration: bool,
|
||||||
system_language: str,
|
system_language: str,
|
||||||
project_version: str,
|
project_version: str,
|
||||||
customEmoji: [],
|
customEmoji: [],
|
||||||
show_node_info_accounts: bool,
|
show_node_info_accounts: bool,
|
||||||
broch_mode: bool) -> ({}, str):
|
broch_mode: bool) -> ({}, str):
|
||||||
"""This is a vestigil mastodon API for the purpose
|
"""This is a vestigil mastodon API for the purpose
|
||||||
of returning an empty result to sites like
|
of returning an empty result to sites like
|
||||||
https://mastopeek.app-dist.eu
|
https://mastopeek.app-dist.eu
|
||||||
|
|
14
metadata.py
14
metadata.py
|
@ -31,11 +31,11 @@ def _getStatusCount(base_dir: str) -> int:
|
||||||
return statusCtr
|
return statusCtr
|
||||||
|
|
||||||
|
|
||||||
def metaDataNodeInfo(base_dir: str,
|
def meta_data_node_info(base_dir: str,
|
||||||
aboutUrl: str,
|
aboutUrl: str,
|
||||||
termsOfServiceUrl: str,
|
termsOfServiceUrl: str,
|
||||||
registration: bool, version: str,
|
registration: bool, version: str,
|
||||||
showAccounts: bool) -> {}:
|
showAccounts: bool) -> {}:
|
||||||
""" /nodeinfo/2.0 endpoint
|
""" /nodeinfo/2.0 endpoint
|
||||||
Also see https://socialhub.activitypub.rocks/t/
|
Also see https://socialhub.activitypub.rocks/t/
|
||||||
fep-f1d5-nodeinfo-in-fediverse-software/1190/4
|
fep-f1d5-nodeinfo-in-fediverse-software/1190/4
|
||||||
|
@ -207,8 +207,8 @@ def metaDataInstance(showAccounts: bool,
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
|
||||||
def metadataCustomEmoji(base_dir: str,
|
def metadata_custom_emoji(base_dir: str,
|
||||||
http_prefix: str, domain_full: str) -> {}:
|
http_prefix: str, domain_full: str) -> {}:
|
||||||
"""Returns the custom emoji
|
"""Returns the custom emoji
|
||||||
Endpoint /api/v1/custom_emojis
|
Endpoint /api/v1/custom_emojis
|
||||||
See https://docs.joinmastodon.org/methods/instance/custom_emojis
|
See https://docs.joinmastodon.org/methods/instance/custom_emojis
|
||||||
|
|
|
@ -47,7 +47,7 @@ from ssb import getSSBAddress
|
||||||
from pgp import getEmailAddress
|
from pgp import getEmailAddress
|
||||||
from pgp import getPGPfingerprint
|
from pgp import getPGPfingerprint
|
||||||
from pgp import getPGPpubKey
|
from pgp import getPGPpubKey
|
||||||
from enigma import getEnigmaPubKey
|
from enigma import get_enigma_pub_key
|
||||||
from tox import getToxAddress
|
from tox import getToxAddress
|
||||||
from briar import getBriarAddress
|
from briar import getBriarAddress
|
||||||
from jami import getJamiAddress
|
from jami import getJamiAddress
|
||||||
|
@ -635,7 +635,7 @@ def htmlProfile(signing_priv_key_pem: str,
|
||||||
donateUrl = getDonationUrl(profile_json)
|
donateUrl = getDonationUrl(profile_json)
|
||||||
websiteUrl = getWebsite(profile_json, translate)
|
websiteUrl = getWebsite(profile_json, translate)
|
||||||
blogAddress = getBlogAddress(profile_json)
|
blogAddress = getBlogAddress(profile_json)
|
||||||
EnigmaPubKey = getEnigmaPubKey(profile_json)
|
EnigmaPubKey = get_enigma_pub_key(profile_json)
|
||||||
PGPpubKey = getPGPpubKey(profile_json)
|
PGPpubKey = getPGPpubKey(profile_json)
|
||||||
PGPfingerprint = getPGPfingerprint(profile_json)
|
PGPfingerprint = getPGPfingerprint(profile_json)
|
||||||
emailAddress = getEmailAddress(profile_json)
|
emailAddress = getEmailAddress(profile_json)
|
||||||
|
@ -2141,7 +2141,7 @@ def htmlEditProfile(css_cache: {}, translate: {}, base_dir: str, path: str,
|
||||||
jamiAddress = getJamiAddress(actor_json)
|
jamiAddress = getJamiAddress(actor_json)
|
||||||
cwtchAddress = getCwtchAddress(actor_json)
|
cwtchAddress = getCwtchAddress(actor_json)
|
||||||
emailAddress = getEmailAddress(actor_json)
|
emailAddress = getEmailAddress(actor_json)
|
||||||
EnigmaPubKey = getEnigmaPubKey(actor_json)
|
EnigmaPubKey = get_enigma_pub_key(actor_json)
|
||||||
PGPpubKey = getPGPpubKey(actor_json)
|
PGPpubKey = getPGPpubKey(actor_json)
|
||||||
PGPfingerprint = getPGPfingerprint(actor_json)
|
PGPfingerprint = getPGPfingerprint(actor_json)
|
||||||
if actor_json.get('name'):
|
if actor_json.get('name'):
|
||||||
|
|
20
webfinger.py
20
webfinger.py
|
@ -214,9 +214,9 @@ def webfinger_meta(http_prefix: str, domain_full: str) -> str:
|
||||||
return metaStr
|
return metaStr
|
||||||
|
|
||||||
|
|
||||||
def webfingerLookup(path: str, base_dir: str,
|
def webfinger_lookup(path: str, base_dir: str,
|
||||||
domain: str, onion_domain: str,
|
domain: str, onion_domain: str,
|
||||||
port: int, debug: bool) -> {}:
|
port: int, debug: bool) -> {}:
|
||||||
"""Lookup the webfinger endpoint for an account
|
"""Lookup the webfinger endpoint for an account
|
||||||
"""
|
"""
|
||||||
if not path.startswith('/.well-known/webfinger?'):
|
if not path.startswith('/.well-known/webfinger?'):
|
||||||
|
@ -279,7 +279,7 @@ def webfingerLookup(path: str, base_dir: str,
|
||||||
return wfJson
|
return wfJson
|
||||||
|
|
||||||
|
|
||||||
def _webfingerUpdateAvatar(wfJson: {}, actor_json: {}) -> bool:
|
def _webfinger_updateAvatar(wfJson: {}, actor_json: {}) -> bool:
|
||||||
"""Updates the avatar image link
|
"""Updates the avatar image link
|
||||||
"""
|
"""
|
||||||
found = False
|
found = False
|
||||||
|
@ -337,7 +337,7 @@ def _webfingerAddBlogLink(wfJson: {}, actor_json: {}) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def _webfingerUpdateFromProfile(wfJson: {}, actor_json: {}) -> bool:
|
def _webfinger_updateFromProfile(wfJson: {}, actor_json: {}) -> bool:
|
||||||
"""Updates webfinger Email/blog/xmpp links from profile
|
"""Updates webfinger Email/blog/xmpp links from profile
|
||||||
Returns true if one or more tags has been changed
|
Returns true if one or more tags has been changed
|
||||||
"""
|
"""
|
||||||
|
@ -411,7 +411,7 @@ def _webfingerUpdateFromProfile(wfJson: {}, actor_json: {}) -> bool:
|
||||||
wfJson['aliases'].remove(fullAlias)
|
wfJson['aliases'].remove(fullAlias)
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
if _webfingerUpdateAvatar(wfJson, actor_json):
|
if _webfinger_updateAvatar(wfJson, actor_json):
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
if _webfingerAddBlogLink(wfJson, actor_json):
|
if _webfingerAddBlogLink(wfJson, actor_json):
|
||||||
|
@ -420,9 +420,9 @@ def _webfingerUpdateFromProfile(wfJson: {}, actor_json: {}) -> bool:
|
||||||
return changed
|
return changed
|
||||||
|
|
||||||
|
|
||||||
def webfingerUpdate(base_dir: str, nickname: str, domain: str,
|
def webfinger_update(base_dir: str, nickname: str, domain: str,
|
||||||
onion_domain: str,
|
onion_domain: str,
|
||||||
cached_webfingers: {}) -> None:
|
cached_webfingers: {}) -> None:
|
||||||
handle = nickname + '@' + domain
|
handle = nickname + '@' + domain
|
||||||
wfSubdir = '/wfendpoints'
|
wfSubdir = '/wfendpoints'
|
||||||
if not os.path.isdir(base_dir + wfSubdir):
|
if not os.path.isdir(base_dir + wfSubdir):
|
||||||
|
@ -446,6 +446,6 @@ def webfingerUpdate(base_dir: str, nickname: str, domain: str,
|
||||||
if not actor_json:
|
if not actor_json:
|
||||||
return
|
return
|
||||||
|
|
||||||
if _webfingerUpdateFromProfile(wfJson, actor_json):
|
if _webfinger_updateFromProfile(wfJson, actor_json):
|
||||||
if save_json(wfJson, filename):
|
if save_json(wfJson, filename):
|
||||||
storeWebfingerInCache(handle, wfJson, cached_webfingers)
|
storeWebfingerInCache(handle, wfJson, cached_webfingers)
|
||||||
|
|
Loading…
Reference in New Issue