diff --git a/daemon.py b/daemon.py index 68b87e7eb..33a83a923 100644 --- a/daemon.py +++ b/daemon.py @@ -5771,6 +5771,48 @@ class PubServer(BaseHTTPRequestHandler): return self._404() + def _showHelpScreenImage(self, callingDomain: str, path: str, + baseDir: str, + GETstartTime, GETtimings: {}) -> None: + """Shows a help screen image + """ + if not path.endswith('.jpg') and \ + not path.endswith('.png') and \ + not path.endswith('.webp') and \ + not path.endswith('.avif') and \ + not path.endswith('.gif'): + return + mediaStr = path.split('/helpimages/')[1] + if '/' not in mediaStr: + if not self.server.themeName: + theme = 'default' + else: + theme = self.server.themeName + iconFilename = mediaStr + else: + theme = mediaStr.split('/')[0] + iconFilename = mediaStr.split('/')[1] + mediaFilename = \ + baseDir + '/theme/' + theme + '/helpimages/' + iconFilename + if self._etag_exists(mediaFilename): + # The file has not changed + self._304() + return + if os.path.isfile(mediaFilename): + with open(mediaFilename, 'rb') as avFile: + mediaBinary = avFile.read() + mimeType = mediaFileMimeType(mediaFilename) + self._set_headers_etag(mediaFilename, + mimeType, + mediaBinary, None, + self.server.domainFull) + self._write(mediaBinary) + self._benchmarkGETtimings(GETstartTime, GETtimings, + 'show files done', + 'help image shown') + return + self._404() + def _showCachedAvatar(self, callingDomain: str, path: str, baseDir: str, GETstartTime, GETtimings: {}) -> None: @@ -11069,6 +11111,14 @@ class PubServer(BaseHTTPRequestHandler): GETstartTime, GETtimings) return + # help screen images + # Note that this comes before the busy flag to avoid conflicts + if self.path.startswith('/helpimages/'): + self._showHelpScreenImage(callingDomain, self.path, + self.server.baseDir, + GETstartTime, GETtimings) + return + self._benchmarkGETtimings(GETstartTime, GETtimings, 'show files done', 'icon shown done') diff --git a/utils.py b/utils.py index 25499145e..b0594c7ae 100644 --- a/utils.py +++ b/utils.py @@ -1274,7 +1274,7 @@ def _isReservedName(nickname: str) -> bool: 'accounts', 'channels', 'profile', 'u', 'updates', 'repeat', 'announce', 'shares', 'fonts', 'icons', 'avatars', - 'welcome') + 'welcome', 'helpimages') if nickname in reservedNames: return True return False