From 9bde90692901a6e373210ec0482e2701486bde57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauri=20V=C3=B5sandi?= Date: Sun, 4 Apr 2021 11:51:11 +0000 Subject: [PATCH] Attribute token.enabled is timestamp, not boolean --- README.md | 13 +++++++++++++ main.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c8b486..44820a4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,16 @@ +# Backgruond + +This component serves allowed list of keyfob UID hashes from MongoDB and +pushes open door commands to door controllers. + +# Testing endpoints + +``` +source .env +curl -f http://doorboy.infra.k-space.ee:5000/allowed -H "KEY: $DOORBOY_SECRET" | md5sum +``` + + # Deploying ``` diff --git a/main.py b/main.py index ac5bc27..a189be7 100644 --- a/main.py +++ b/main.py @@ -24,7 +24,7 @@ async def view_doorboy_uids(request): async for obj in db.member.find({"enabled": True}): allowed_names.append(obj["_id"]) allowed_uids = [] - async for obj in db.inventory.find({"token.uid_hash": {"$exists":True}, "inventory.owner_id": {"$exists":True}, "token.enabled": True}, {"inventory.owner_id": True, "token.uid_hash": True }): + async for obj in db.inventory.find({"token.uid_hash": {"$exists":True}, "inventory.owner_id": {"$exists":True}, "token.enabled": {"$exists":True}}, {"inventory.owner_id": True, "token.uid_hash": True }): if obj["inventory"].pop("owner_id") in allowed_names: del obj["_id"] del obj["inventory"]