|
@@ -134,6 +134,7 @@ async def reloadCallback(mngr: Manager, msg: Message):
|
|
|
await refreshDevicesCache()
|
|
await refreshDevicesCache()
|
|
|
await refreshStatesCache()
|
|
await refreshStatesCache()
|
|
|
await refreshQueuesCache()
|
|
await refreshQueuesCache()
|
|
|
|
|
+ await rebindLostDevices()
|
|
|
|
|
|
|
|
@manager.register_event('ExtensionStatus')
|
|
@manager.register_event('ExtensionStatus')
|
|
|
async def extensionStatusCallback(mngr: Manager, msg: Message):
|
|
async def extensionStatusCallback(mngr: Manager, msg: Message):
|
|
@@ -564,6 +565,19 @@ async def refreshQueuesCache():
|
|
|
app.cache['queues'] = await amiQueues()
|
|
app.cache['queues'] = await amiQueues()
|
|
|
return len(app.cache['queues'])
|
|
return len(app.cache['queues'])
|
|
|
|
|
|
|
|
|
|
+async def rebindLostDevices():
|
|
|
|
|
+ ast = await getGlobalVars()
|
|
|
|
|
+ for device in app.cache['devices']:
|
|
|
|
|
+ user = await getDeviceUser(device)
|
|
|
|
|
+ if (user != 'none') and (user in app.cache['ustates'].keys()):
|
|
|
|
|
+ _device = await getUserDevice(_user)
|
|
|
|
|
+ if _device != device:
|
|
|
|
|
+ app.logger.warning('Fixing bind user {} to device {}'.format(user, device))
|
|
|
|
|
+ dial = await getDeviceDial(device)
|
|
|
|
|
+ await setUserHint(user, dial, ast) # Set hints for user on new device
|
|
|
|
|
+ await setUserDeviceStates(user, device, ast) # Set device states for users device
|
|
|
|
|
+ await setUserDevice(user, device) # Bind device to user
|
|
|
|
|
+
|
|
|
async def userStateChangeCallback(user, state, prevState = None):
|
|
async def userStateChangeCallback(user, state, prevState = None):
|
|
|
reply = None
|
|
reply = None
|
|
|
if ((app.config['STATE_CALLBACK_URL'] not in NONEs) and
|
|
if ((app.config['STATE_CALLBACK_URL'] not in NONEs) and
|