diff --git a/daemon.py b/daemon.py index 5887cca9..78897c3c 100644 --- a/daemon.py +++ b/daemon.py @@ -195,6 +195,7 @@ from media import removeMetaData from cache import storePersonInCache from cache import getPersonFromCache from httpsig import verifyPostHeaders +from theme import setNewsAvatar from theme import setTheme from theme import getTheme from theme import enableGrayscale @@ -3412,6 +3413,11 @@ class PubServer(BaseHTTPRequestHandler): setTheme(baseDir, fields['themeDropdown'], domain) + setNewsAvatar(baseDir, + fields['themeDropdown'], + httpPrefix, + domain, + domainFull) # change email address currentEmailAddress = getEmailAddress(actorJson) diff --git a/epicyon.py b/epicyon.py index 775d6868..ffc432bd 100644 --- a/epicyon.py +++ b/epicyon.py @@ -69,6 +69,7 @@ from shares import sendShareViaServer from shares import sendUndoShareViaServer from shares import addShare from theme import setTheme +from theme import setNewsAvatar from announce import sendAnnounceViaServer from socnet import instancesGraph import argparse @@ -1937,6 +1938,15 @@ if YTDomain: if setTheme(baseDir, themeName, domain): print('Theme set to ' + themeName) + domainFull = domain + if port != 80 and port != 443: + domainFull = domain + ':' + str(port) + setNewsAvatar(baseDir, + themeName, + httpPrefix, + domain, + domainFull) + if __name__ == "__main__": runDaemon(args.dateonly, args.votingtime, diff --git a/theme.py b/theme.py index 5c827f27..49f9c20a 100644 --- a/theme.py +++ b/theme.py @@ -1008,6 +1008,27 @@ def setThemeImages(baseDir: str, name: str) -> None: pass +def setNewsAvatar(baseDir: str, name: str, + httpPrefix: str, + domain: str, domainFull: str) -> None: + """Sets the avatar for the news account + """ + nickname = 'news' + newFilename = baseDir + '/img/icons/' + name + '/avatar_news.png' + if not os.path.isfile(newFilename): + return + filename = baseDir + 'cache/avatars/' + \ + httpPrefix + '://' + domainFull + '/users/' + nickname + \ + '.png' + if os.path.isfile(filename): + os.remove(filename) + if os.path.isdir(baseDir + 'cache/avatars'): + copyfile(newFilename, filename) + copyfile(newFilename, + baseDir + '/accounts/' + + nickname + '@' + domain + '/avatar.png') + + def setTheme(baseDir: str, name: str, domain: str) -> bool: result = False