|
@@ -233,8 +233,8 @@ async def celCallback(mngr: Manager, msg: Message):
|
|
|
reply = await app.config['HTTP_CLIENT'].post(row['url'],
|
|
reply = await app.config['HTTP_CLIENT'].post(row['url'],
|
|
|
json=values)
|
|
json=values)
|
|
|
else:
|
|
else:
|
|
|
- app.logger.warning('no url for {}'.format(cid))
|
|
|
|
|
- if (msg.EventName == 'CHAN_END') and (msg.Context in ('from-queue')) and ('HTTP_CLIENT' in app.config) and ('answered' not in first_message):#end dial
|
|
|
|
|
|
|
+ app.logger.warning('no url for {}'.format(cid))
|
|
|
|
|
+ if (msg.EventName == 'CHAN_END') and msg.Context in ('from-queue') and ('HTTP_CLIENT' in app.config) and ('answered' not in first_message):#end dial
|
|
|
called = msg.CallerIDname
|
|
called = msg.CallerIDname
|
|
|
app.cache['cel_calls'][uid]['channels'].pop(called, False)
|
|
app.cache['cel_calls'][uid]['channels'].pop(called, False)
|
|
|
app.logger.warning('NEW CALLING LIST {}'.format(','.join(app.cache['cel_calls'][uid]['channels'].keys())))
|
|
app.logger.warning('NEW CALLING LIST {}'.format(','.join(app.cache['cel_calls'][uid]['channels'].keys())))
|
|
@@ -1251,5 +1251,93 @@ class DeviceCallback(Resource):
|
|
|
url = row['url']
|
|
url = row['url']
|
|
|
return successCallbackURL(device, url)
|
|
return successCallbackURL(device, url)
|
|
|
|
|
|
|
|
|
|
+@app.route('/group/ringing/callback')
|
|
|
|
|
+class GroupRingingCallback(Resource):
|
|
|
|
|
+ @authRequired
|
|
|
|
|
+ @app.param('url', 'used to set the Callback url for the group ringing callback', 'query')
|
|
|
|
|
+ @app.response(HTTPStatus.OK, 'JSON data {"url":url}')
|
|
|
|
|
+ @app.response(HTTPStatus.UNAUTHORIZED, 'Authorization required')
|
|
|
|
|
+ async def get(self, device):
|
|
|
|
|
+ '''Returns and sets groupRinging callback url.
|
|
|
|
|
+ '''
|
|
|
|
|
+ if not request.admin:
|
|
|
|
|
+ abort(401)
|
|
|
|
|
+ url = request.args.get('url', None)
|
|
|
|
|
+ if url is not None:
|
|
|
|
|
+ await db.execute(query='REPLACE INTO callback_urls (device, url) VALUES (:device, :url)',
|
|
|
|
|
+ values={'device': 'groupRinging','url': url})
|
|
|
|
|
+ else:
|
|
|
|
|
+ row = await db.fetch_one(query='SELECT url FROM callback_urls WHERE device = :device',
|
|
|
|
|
+ values={'device': 'groupRinging'})
|
|
|
|
|
+ if row is not None:
|
|
|
|
|
+ url = row['url']
|
|
|
|
|
+ return successCommonCallbackURL('groupRinging', url)
|
|
|
|
|
+
|
|
|
|
|
+@app.route('/group/answered/callback')
|
|
|
|
|
+class GroupAnsweredCallback(Resource):
|
|
|
|
|
+ @authRequired
|
|
|
|
|
+ @app.param('url', 'used to set the Callback url for the group answered callback', 'query')
|
|
|
|
|
+ @app.response(HTTPStatus.OK, 'JSON data {"url":url}')
|
|
|
|
|
+ @app.response(HTTPStatus.UNAUTHORIZED, 'Authorization required')
|
|
|
|
|
+ async def get(self, device):
|
|
|
|
|
+ '''Returns and sets groupAnswered callback url.
|
|
|
|
|
+ '''
|
|
|
|
|
+ if not request.admin:
|
|
|
|
|
+ abort(401)
|
|
|
|
|
+ url = request.args.get('url', None)
|
|
|
|
|
+ if url is not None:
|
|
|
|
|
+ await db.execute(query='REPLACE INTO callback_urls (device, url) VALUES (:device, :url)',
|
|
|
|
|
+ values={'device': 'groupAnswered','url': url})
|
|
|
|
|
+ else:
|
|
|
|
|
+ row = await db.fetch_one(query='SELECT url FROM callback_urls WHERE device = :device',
|
|
|
|
|
+ values={'device': 'groupAnswered'})
|
|
|
|
|
+ if row is not None:
|
|
|
|
|
+ url = row['url']
|
|
|
|
|
+ return successCommonCallbackURL('groupAnswered', url)
|
|
|
|
|
+
|
|
|
|
|
+@app.route('/queue/enter/callback')
|
|
|
|
|
+class QueueEnterCallback(Resource):
|
|
|
|
|
+ @authRequired
|
|
|
|
|
+ @app.param('url', 'used to set the Callback url for the queue enter callback', 'query')
|
|
|
|
|
+ @app.response(HTTPStatus.OK, 'JSON data {"url":url}')
|
|
|
|
|
+ @app.response(HTTPStatus.UNAUTHORIZED, 'Authorization required')
|
|
|
|
|
+ async def get(self, device):
|
|
|
|
|
+ '''Returns and sets queueEnter callback url.
|
|
|
|
|
+ '''
|
|
|
|
|
+ if not request.admin:
|
|
|
|
|
+ abort(401)
|
|
|
|
|
+ url = request.args.get('url', None)
|
|
|
|
|
+ if url is not None:
|
|
|
|
|
+ await db.execute(query='REPLACE INTO callback_urls (device, url) VALUES (:device, :url)',
|
|
|
|
|
+ values={'device': 'queueEnter','url': url})
|
|
|
|
|
+ else:
|
|
|
|
|
+ row = await db.fetch_one(query='SELECT url FROM callback_urls WHERE device = :device',
|
|
|
|
|
+ values={'device': 'queueEnter'})
|
|
|
|
|
+ if row is not None:
|
|
|
|
|
+ url = row['url']
|
|
|
|
|
+ return successCommonCallbackURL('queueEnter', url)
|
|
|
|
|
+
|
|
|
|
|
+@app.route('/queue/leave/callback')
|
|
|
|
|
+class QueueLeaveCallback(Resource):
|
|
|
|
|
+ @authRequired
|
|
|
|
|
+ @app.param('url', 'used to set the Callback url for the queue leave callback', 'query')
|
|
|
|
|
+ @app.response(HTTPStatus.OK, 'JSON data {"url":url}')
|
|
|
|
|
+ @app.response(HTTPStatus.UNAUTHORIZED, 'Authorization required')
|
|
|
|
|
+ async def get(self, device):
|
|
|
|
|
+ '''Returns and sets queueLeave callback url.
|
|
|
|
|
+ '''
|
|
|
|
|
+ if not request.admin:
|
|
|
|
|
+ abort(401)
|
|
|
|
|
+ url = request.args.get('url', None)
|
|
|
|
|
+ if url is not None:
|
|
|
|
|
+ await db.execute(query='REPLACE INTO callback_urls (device, url) VALUES (:device, :url)',
|
|
|
|
|
+ values={'device': 'queueLeave','url': url})
|
|
|
|
|
+ else:
|
|
|
|
|
+ row = await db.fetch_one(query='SELECT url FROM callback_urls WHERE device = :device',
|
|
|
|
|
+ values={'device': 'queueLeave'})
|
|
|
|
|
+ if row is not None:
|
|
|
|
|
+ url = row['url']
|
|
|
|
|
+ return successCommonCallbackURL('queueLeave', url)
|
|
|
|
|
+
|
|
|
manager.connect()
|
|
manager.connect()
|
|
|
app.run(loop=main_loop, host='0.0.0.0', port=app.config['PORT'])
|
|
app.run(loop=main_loop, host='0.0.0.0', port=app.config['PORT'])
|