Attribute token.enabled is timestamp, not boolean

This commit is contained in:
Lauri Võsandi 2021-04-04 11:51:11 +00:00
parent bca9264ce9
commit 9bde906929
2 changed files with 14 additions and 1 deletions

View File

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

View File

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