diff --git a/daemon.py b/daemon.py index b939ab283..6c4b31b3e 100644 --- a/daemon.py +++ b/daemon.py @@ -29,6 +29,7 @@ from mastoapiv1 import getMastApiV1Id from mastoapiv1 import getNicknameFromMastoApiV1Id from metadata import metaDataInstance from metadata import metaDataNodeInfo +from metadata import metadataCustomEmoji from pgp import getEmailAddress from pgp import setEmailAddress from pgp import getPGPpubKey @@ -867,7 +868,8 @@ class PubServer(BaseHTTPRequestHandler): translate: {}, registration: bool, systemLanguage: str, - projectVersion: str) -> bool: + projectVersion: str, + customEmoji: []) -> bool: """This is a vestigil mastodon API for the purpose of returning an empty result to sites like https://mastopeek.app-dist.eu @@ -944,6 +946,9 @@ class PubServer(BaseHTTPRequestHandler): elif path.startswith('/api/v1/timelines'): sendJson = [] sendJsonStr = 'masto API timelines sent' + elif path.startswith('/api/v1/custom_emojis'): + sendJson = customEmoji + sendJsonStr = 'masto API custom emojis sent' adminNickname = getConfigParam(baseDir, 'admin') if adminNickname and path == '/api/v1/instance': @@ -1019,12 +1024,13 @@ class PubServer(BaseHTTPRequestHandler): translate: {}, registration: bool, systemLanguage: str, - projectVersion: str) -> bool: + projectVersion: str, + customEmoji: []) -> bool: return self._mastoApiV1(path, callingDomain, authorized, httpPrefix, baseDir, nickname, domain, domainFull, onionDomain, i2pDomain, translate, registration, systemLanguage, - projectVersion) + projectVersion, customEmoji) def _nodeinfo(self, callingDomain: str) -> bool: if not self.path.startswith('/nodeinfo/2.0'): @@ -10757,7 +10763,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.translate, self.server.registration, self.server.systemLanguage, - self.server.projectVersion): + self.server.projectVersion, + self.server.customEmoji): return self._benchmarkGETtimings(GETstartTime, GETtimings, @@ -15113,6 +15120,10 @@ def runDaemon(city: str, # cache to store css files 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 setBrochMode(baseDir, httpd.domainFull, brochMode) diff --git a/metadata.py b/metadata.py index c8bee73c1..e073692c3 100644 --- a/metadata.py +++ b/metadata.py @@ -128,3 +128,30 @@ def metaDataInstance(instanceTitle: str, } 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 diff --git a/orgs/instance.txt b/orgs/instance.txt deleted file mode 100644 index a797b348d..000000000 --- a/orgs/instance.txt +++ /dev/null @@ -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: [] - } - } - } -} diff --git a/orgs/protest.txt b/orgs/protest.txt deleted file mode 100644 index 19efc83e1..000000000 --- a/orgs/protest.txt +++ /dev/null @@ -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: [] - } - } - } -} diff --git a/orgs/publication.txt b/orgs/publication.txt deleted file mode 100644 index 511400222..000000000 --- a/orgs/publication.txt +++ /dev/null @@ -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: [] - } - } - } - } -}