Set the news avatar if it exists

main
Bob Mottram 2020-10-13 22:38:19 +01:00
parent 9c442d0a0c
commit d25be97de0
3 changed files with 37 additions and 0 deletions

View File

@ -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)

View File

@ -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,

View File

@ -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