Merge branch 'main' of ssh://code.freedombone.net:2222/bashrc/epicyon

main
Bob Mottram 2021-05-28 10:25:34 +01:00
commit b951b5017f
5 changed files with 42 additions and 181 deletions

View File

@ -29,6 +29,7 @@ from mastoapiv1 import getMastApiV1Id
from mastoapiv1 import getNicknameFromMastoApiV1Id from mastoapiv1 import getNicknameFromMastoApiV1Id
from metadata import metaDataInstance from metadata import metaDataInstance
from metadata import metaDataNodeInfo from metadata import metaDataNodeInfo
from metadata import metadataCustomEmoji
from pgp import getEmailAddress from pgp import getEmailAddress
from pgp import setEmailAddress from pgp import setEmailAddress
from pgp import getPGPpubKey from pgp import getPGPpubKey
@ -867,7 +868,8 @@ class PubServer(BaseHTTPRequestHandler):
translate: {}, translate: {},
registration: bool, registration: bool,
systemLanguage: str, systemLanguage: str,
projectVersion: str) -> bool: projectVersion: str,
customEmoji: []) -> bool:
"""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
@ -944,6 +946,9 @@ class PubServer(BaseHTTPRequestHandler):
elif path.startswith('/api/v1/timelines'): elif path.startswith('/api/v1/timelines'):
sendJson = [] sendJson = []
sendJsonStr = 'masto API timelines sent' sendJsonStr = 'masto API timelines sent'
elif path.startswith('/api/v1/custom_emojis'):
sendJson = customEmoji
sendJsonStr = 'masto API custom emojis sent'
adminNickname = getConfigParam(baseDir, 'admin') adminNickname = getConfigParam(baseDir, 'admin')
if adminNickname and path == '/api/v1/instance': if adminNickname and path == '/api/v1/instance':
@ -1019,12 +1024,13 @@ class PubServer(BaseHTTPRequestHandler):
translate: {}, translate: {},
registration: bool, registration: bool,
systemLanguage: str, systemLanguage: str,
projectVersion: str) -> bool: projectVersion: str,
customEmoji: []) -> bool:
return self._mastoApiV1(path, callingDomain, authorized, return self._mastoApiV1(path, callingDomain, authorized,
httpPrefix, baseDir, nickname, domain, httpPrefix, baseDir, nickname, domain,
domainFull, onionDomain, i2pDomain, domainFull, onionDomain, i2pDomain,
translate, registration, systemLanguage, translate, registration, systemLanguage,
projectVersion) projectVersion, customEmoji)
def _nodeinfo(self, callingDomain: str) -> bool: def _nodeinfo(self, callingDomain: str) -> bool:
if not self.path.startswith('/nodeinfo/2.0'): if not self.path.startswith('/nodeinfo/2.0'):
@ -10757,7 +10763,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.translate, self.server.translate,
self.server.registration, self.server.registration,
self.server.systemLanguage, self.server.systemLanguage,
self.server.projectVersion): self.server.projectVersion,
self.server.customEmoji):
return return
self._benchmarkGETtimings(GETstartTime, GETtimings, self._benchmarkGETtimings(GETstartTime, GETtimings,
@ -15113,6 +15120,10 @@ def runDaemon(city: str,
# cache to store css files # cache to store css files
httpd.cssCache = {} httpd.cssCache = {}
# get the list of custom emoji, for use by the mastodon api
httpd.customEmoji = \
metadataCustomEmoji(baseDir, httpPrefix, httpd.domainFull)
# whether to enable broch mode, which locks down the instance # whether to enable broch mode, which locks down the instance
setBrochMode(baseDir, httpd.domainFull, brochMode) setBrochMode(baseDir, httpd.domainFull, brochMode)

View File

@ -128,3 +128,30 @@ def metaDataInstance(instanceTitle: str,
} }
return instance return instance
def metadataCustomEmoji(baseDir: str,
httpPrefix: str, domainFull: str) -> {}:
"""Returns the custom emoji
Endpoint /api/v1/custom_emojis
See https://docs.joinmastodon.org/methods/instance/custom_emojis
"""
result = []
emojisUrl = httpPrefix + '://' + domainFull + '/emoji'
for subdir, dirs, files in os.walk(baseDir + '/emoji'):
for f in files:
if len(f) < 3:
continue
if f[0].isdigit() or f[1].isdigit():
continue
if not f.endswith('.png'):
continue
url = os.path.join(emojisUrl, f)
result.append({
"shortcode": f.replace('.png', ''),
"url": url,
"static_url": url,
"visible_in_picker": True
})
break
return result

View File

@ -1,21 +0,0 @@
{
"Administrator": {
description: "Administrator of the instance",
iconUrl: "",
members: [],
team: {
"Moderator": {
description: "Can moderate posts, suspend members and block instances",
pitch: "",
iconUrl: "",
members: []
},
"Delegator": {
description: "Can delegate roles",
pitch: "",
iconUrl: "",
members: []
}
}
}
}

View File

@ -1,98 +0,0 @@
{
"General meeting": {
"Safety": {
"Legal team": {
description: "",
pitch: "",
iconUrl: "",
members: []
},
"Legal observers": {
description: "",
pitch: "",
iconUrl: "",
members: []
},
"Jail support": {
description: "",
pitch: "",
iconUrl: "",
members: []
},
"Medics team": {
description: "",
pitch: "",
iconUrl: "",
members: []
},
"Recovery team": {
description: "",
pitch: "",
iconUrl: "",
members: []
}
}
},
"Organizing": {
"Logistics": {
"Police spokesperson": {
description: "",
pitch: "",
iconUrl: "",
members: []
},
"Self defense team": {
description: "",
pitch: "",
iconUrl: "",
members: []
},
"Spotters": {
description: "",
pitch: "",
iconUrl: "",
members: []
}
},
"Message": {
"Media spokesperson": {
description: "",
pitch: "",
iconUrl: "",
members: []
},
"Writer": {
description: "",
pitch: "",
iconUrl: "",
members: []
}
},
"Mobilization": {
"Meme artist": {
description: "",
pitch: "",
iconUrl: "",
members: []
},
"Banner visuals": {
description: "",
pitch: "",
iconUrl: "",
members: []
},
"Social media": {
description: "",
pitch: "",
iconUrl: "",
members: []
},
"Video producer": {
description: "",
pitch: "",
iconUrl: "",
members: []
}
}
}
}

View File

@ -1,58 +0,0 @@
{
"Chief Editor": {
description: "",
pitch: "",
iconUrl: "",
members: [],
team: {
"Creative": {
"Photographer": {
description: "",
pitch: "",
iconUrl: "",
members: []
},
"Layout editor": {
description: "",
pitch: "",
iconUrl: "",
members: []
},
"Writers team": {
description: "",
pitch: "",
iconUrl: "",
members: []
}
},
"Copy": {
"Proof reader": {
description: "",
pitch: "",
iconUrl: "",
members: []
},
"Fact checker": {
description: "",
pitch: "",
iconUrl: "",
members: []
}
},
"Publicity": {
"Website designer": {
description: "",
pitch: "",
iconUrl: "",
members: []
},
"Social media publicist": {
description: "",
pitch: "",
iconUrl: "",
members: []
}
}
}
}
}