Show handle qrcode

main
Bob Mottram 2020-06-21 16:12:42 +00:00
parent c1a2f82e80
commit 117b231230
1 changed files with 37 additions and 0 deletions

View File

@ -39,6 +39,7 @@ from matrix import getMatrixAddress
from matrix import setMatrixAddress from matrix import setMatrixAddress
from donate import getDonationUrl from donate import getDonationUrl
from donate import setDonationUrl from donate import setDonationUrl
from person import savePersonQrcode
from person import randomizeActorImages from person import randomizeActorImages
from person import personUpgradeActor from person import personUpgradeActor
from person import activateAccount from person import activateAccount
@ -1796,6 +1797,42 @@ class PubServer(BaseHTTPRequestHandler):
self._404() self._404()
return return
# QR code for account handle
if '/users/' in self.path and \
self.path.endswith('/qrcode.png'):
nickname = getNicknameFromActor(self.path)
savePersonQrcode(self.server.baseDir,
nickname, self.server.domain,
self.server.port)
mediaFilename = \
self.server.baseDir + '/accounts/' + \
nickname + '@' + self.server.domain + '/qrcode.png'
if os.path.isfile(mediaFilename):
if self._etag_exists(mediaFilename):
# The file has not changed
self._304()
return
tries = 0
mediaBinary = None
while tries < 5:
try:
with open(mediaFilename, 'rb') as avFile:
mediaBinary = avFile.read()
break
except Exception as e:
print(e)
time.sleep(1)
tries += 1
if mediaBinary:
self._set_headers_etag(mediaFilename, 'image/png',
mediaBinary, cookie,
callingDomain)
self._write(mediaBinary)
return
self._404()
return
# search screen banner image # search screen banner image
if '/users/' in self.path and \ if '/users/' in self.path and \
self.path.endswith('/search_banner.png'): self.path.endswith('/search_banner.png'):