fix display pairing and add scoped family voice announcements
This commit is contained in:
@@ -44,6 +44,7 @@ import journal
|
||||
import ptz
|
||||
import displays
|
||||
import member_locations as family_locations
|
||||
import family_voice
|
||||
import family_members
|
||||
import recording_archive
|
||||
import app_downloads
|
||||
@@ -100,6 +101,7 @@ JOURNAL = journal.Journal(sys.modules[__name__])
|
||||
CLOUD_IMAGES = cloud_images.CloudImages(sys.modules[__name__])
|
||||
DISPLAYS = displays.Displays(sys.modules[__name__])
|
||||
LOCATIONS = family_locations.Locations(sys.modules[__name__])
|
||||
VOICE = family_voice.Voice(sys.modules[__name__])
|
||||
MEMBERS = family_members.Members(sys.modules[__name__])
|
||||
ARCHIVE = recording_archive.Archive(sys.modules[__name__])
|
||||
|
||||
@@ -692,6 +694,10 @@ class Handler(BaseHTTPRequestHandler):
|
||||
def do_POST(self):
|
||||
try:
|
||||
path = url.urlsplit(self.path).path
|
||||
if path == '/api/voice':
|
||||
authorization=self.headers.get('Authorization','')
|
||||
self.answer(VOICE.native(authorization[7:] if authorization.startswith('Bearer ') else '',self.body(220000)))
|
||||
return
|
||||
if path == '/api/location/update':
|
||||
authorization=self.headers.get('Authorization','')
|
||||
self.answer(LOCATIONS.native(authorization[7:] if authorization.startswith('Bearer ') else '',self.body(16384)))
|
||||
@@ -737,6 +743,8 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self.answer({'ok': True}, cookie='vision=; Path=/; Max-Age=0; HttpOnly; SameSite=Strict')
|
||||
elif path == '/api/locations':
|
||||
self.answer(LOCATIONS.manage(self.user,data))
|
||||
elif path == '/api/display-voice':
|
||||
self.answer(VOICE.manage_display(self.user,data))
|
||||
elif path == '/api/members':
|
||||
self.answer(MEMBERS.save(self.user,data))
|
||||
elif path == '/api/genealogy/share':
|
||||
@@ -980,10 +988,10 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self.connection.settimeout(old_timeout)
|
||||
|
||||
def do_HEAD(self):
|
||||
if url.urlsplit(self.path).path != '/downloads/ZhaoDisplay.apk':
|
||||
if url.urlsplit(self.path).path not in ('/downloads/ZhaoDisplay.apk','/downloads/ZhaoTerminal.apk'):
|
||||
self.send_response(405); self.send_header('Content-Length','0'); self.end_headers(); return
|
||||
try:
|
||||
self.require_auth(); app_downloads.serve(self,sys.modules[__name__])
|
||||
self.require_auth(); app_downloads.serve(self,sys.modules[__name__],'terminal' if url.urlsplit(self.path).path.endswith('ZhaoTerminal.apk') else 'phone')
|
||||
except Problem as exc:
|
||||
self.send_response(exc.status); self.send_header('Content-Length','0'); self.end_headers()
|
||||
|
||||
@@ -992,10 +1000,10 @@ class Handler(BaseHTTPRequestHandler):
|
||||
parsed = url.urlsplit(self.path)
|
||||
path = parsed.path
|
||||
query = {k: v[0] for k, v in url.parse_qs(parsed.query).items()}
|
||||
if path in ('/api/app-release','/downloads/ZhaoDisplay.apk'):
|
||||
if path in ('/api/app-release','/downloads/ZhaoDisplay.apk','/downloads/ZhaoTerminal.apk'):
|
||||
self.require_auth()
|
||||
if path == '/api/app-release': self.answer(app_downloads.release(sys.modules[__name__])[1])
|
||||
else: app_downloads.serve(self,sys.modules[__name__])
|
||||
if path == '/api/app-release': self.answer(app_downloads.release(sys.modules[__name__],query.get('variant','phone'))[1])
|
||||
else: app_downloads.serve(self,sys.modules[__name__],'terminal' if path.endswith('ZhaoTerminal.apk') else 'phone')
|
||||
return
|
||||
if path == baidu.CALLBACK:
|
||||
try:
|
||||
@@ -1273,6 +1281,7 @@ def initialize():
|
||||
MEMBERS.initialize()
|
||||
DISPLAYS.initialize()
|
||||
LOCATIONS.initialize()
|
||||
VOICE.initialize()
|
||||
ARCHIVE.initialize()
|
||||
HERITAGE.initialize()
|
||||
JOURNAL.initialize()
|
||||
@@ -1295,6 +1304,7 @@ if __name__ == '__main__':
|
||||
threading.Thread(target=media_config_watch, daemon=True).start()
|
||||
threading.Thread(target=BACKUPS.watch, daemon=True).start()
|
||||
threading.Thread(target=DISPLAYS.watch, daemon=True).start()
|
||||
threading.Thread(target=VOICE.watch, daemon=True).start()
|
||||
threading.Thread(target=ARCHIVE.watch, daemon=True).start()
|
||||
threading.Thread(target=JOURNAL.watch, daemon=True).start()
|
||||
bindings = [h.strip() for h in os.environ.get('VISION_BIND', '127.0.0.1').split(',') if h.strip()]
|
||||
|
||||
Reference in New Issue
Block a user