reset connection status at startup

reset bot and client connections to false for xmpp/mqtt at startup
This commit is contained in:
Brian Martin 2020-01-20 08:34:08 -05:00
parent 3b7b31af47
commit bdc452b99c
2 changed files with 14 additions and 0 deletions

View file

@ -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()

View file

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