From bdc452b99c7a424a15f39b3a6922a88a23d61983 Mon Sep 17 00:00:00 2001 From: Brian Martin Date: Mon, 20 Jan 2020 08:34:08 -0500 Subject: [PATCH] reset connection status at startup reset bot and client connections to false for xmpp/mqtt at startup --- bumper/__init__.py | 3 +++ bumper/db.py | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/bumper/__init__.py b/bumper/__init__.py index 8369477..5b1c079 100644 --- a/bumper/__init__.py +++ b/bumper/__init__.py @@ -171,6 +171,9 @@ xmpp_listen_port = 5223 async def start(): + #Reset xmpp/mqtt to false in database for bots and clients + bot_reset_connectionStatus() + client_reset_connectionStatus() try: loop = asyncio.get_event_loop() diff --git a/bumper/db.py b/bumper/db.py index 71c158a..3bb4b39 100644 --- a/bumper/db.py +++ b/bumper/db.py @@ -289,6 +289,11 @@ def bot_remove(did): if bot: bots.remove(doc_ids=[bot.doc_id]) +def bot_reset_connectionStatus(): + bots = db_get().table("bots") + for bot in bots: + bot_set_mqtt(bot["did"], False) + bot_set_xmpp(bot["did"], False) def bot_get(did): bots = db_get().table("bots") @@ -345,6 +350,12 @@ def client_add(userid, realm, resource): bumperlog.info("Adding new client with resource {}".format(newclient.resource)) client_full_upsert(newclient.asdict()) +def client_reset_connectionStatus(): + clients = db_get().table("clients") + for client in clients: + client_set_mqtt(client["resource"], False) + client_set_xmpp(client["resource"], False) + def client_remove(resource): clients = db_get().table("clients") client = client_get(resource)