Add approval checking
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful

This commit is contained in:
Madis Mägi 2023-08-11 18:20:01 +03:00
parent f0ca73329b
commit 13faabf01f

View File

@ -76,7 +76,7 @@ async def view_longpoll(request):
async with app.ctx.db.eventlog.watch(pipeline) as stream: async with app.ctx.db.eventlog.watch(pipeline) as stream:
await response.send("data: watch-stream-opened\n\n") await response.send("data: watch-stream-opened\n\n")
async for event in stream: async for event in stream:
if event["fullDocument"].get("type") == "open-door": if event["fullDocument"].get("type") == "open-door" and event["fullDocument"].get("approved", False):
await response.send("data: %s\n\n" % await response.send("data: %s\n\n" %
event["fullDocument"]["door"]) event["fullDocument"]["door"])
except pymongo.errors.PyMongoError as e: except pymongo.errors.PyMongoError as e: