Built motion from commit 14588770.|2.5.38
[motion2.git] / server / api / squareRecording / squareRecording.rpc.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x8825=['create','body','options','raw','then','lodash','util','bluebird','../../config/utils','../../config/logger','rpc','../../config/environment','http','request','SquareRecording,\x20%s,\x20%s','request\x20sent','debug','SquareRecording,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','CreateSquareRecording'];(function(_0x1cd43b,_0x553cc7){var _0x1b6231=function(_0x2bbe15){while(--_0x2bbe15){_0x1cd43b['push'](_0x1cd43b['shift']());}};_0x1b6231(++_0x553cc7);}(_0x8825,0x1d9));var _0x5882=function(_0x3d75f2,_0x3e4377){_0x3d75f2=_0x3d75f2-0x0;var _0x129ffb=_0x8825[_0x3d75f2];return _0x129ffb;};'use strict';var _=require(_0x5882('0x0'));var util=require(_0x5882('0x1'));var moment=require('moment');var BPromise=require(_0x5882('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x5882('0x3'));var logger=require(_0x5882('0x4'))(_0x5882('0x5'));var config=require(_0x5882('0x6'));var jayson=require('jayson/promise');var client=jayson['client'][_0x5882('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x334ed2,_0x2ca29e,_0x46260e){return new BPromise(function(_0x3c301d,_0xc7fbe9){return client[_0x5882('0x8')](_0x334ed2,_0x46260e)['then'](function(_0x1a4938){logger['info'](_0x5882('0x9'),_0x2ca29e,_0x5882('0xa'));logger[_0x5882('0xb')](_0x5882('0xc'),_0x2ca29e,_0x5882('0xa'),JSON[_0x5882('0xd')](_0x1a4938));if(_0x1a4938[_0x5882('0xe')]){if(_0x1a4938[_0x5882('0xe')][_0x5882('0xf')]===0x1f4){logger['error'](_0x5882('0x9'),_0x2ca29e,_0x1a4938['error'][_0x5882('0x10')]);return _0xc7fbe9(_0x1a4938[_0x5882('0xe')][_0x5882('0x10')]);}logger[_0x5882('0xe')](_0x5882('0x9'),_0x2ca29e,_0x1a4938['error'][_0x5882('0x10')]);return _0x3c301d(_0x1a4938[_0x5882('0xe')]['message']);}else{logger[_0x5882('0x11')](_0x5882('0x9'),_0x2ca29e,_0x5882('0xa'));_0x3c301d(_0x1a4938[_0x5882('0x12')]['message']);}})[_0x5882('0x13')](function(_0x2388dc){logger[_0x5882('0xe')](_0x5882('0x9'),_0x2ca29e,_0x2388dc);_0xc7fbe9(_0x2388dc);});});}exports[_0x5882('0x14')]=function(_0x409891){var _0x38dd9f=this;return new Promise(function(_0x111d88,_0x328491){return db['SquareRecording'][_0x5882('0x15')](_0x409891[_0x5882('0x16')],{'raw':_0x409891['options']?_0x409891[_0x5882('0x17')][_0x5882('0x18')]===undefined?!![]:![]:!![]})[_0x5882('0x19')](function(_0x4e9c42){logger['info']('CreateSquareRecording',_0x409891);logger[_0x5882('0xb')](_0x5882('0x14'),_0x409891,JSON[_0x5882('0xd')](_0x4e9c42));_0x111d88(_0x4e9c42);})[_0x5882('0x13')](function(_0x2b077b){logger['error'](_0x5882('0x14'),_0x2b077b['message'],_0x409891);_0x328491(_0x38dd9f[_0x5882('0xe')](0x1f4,_0x2b077b[_0x5882('0x10')]));});});};