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