Built motion from commit ddca4d0d.|2.5.47
[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 _0x62a6=['client','http','then','SquareRecording,\x20%s,\x20%s','request\x20sent','debug','SquareRecording,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','SquareRecording','create','body','options','info','CreateSquareRecording','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x3544dc,_0x1fac28){var _0x4fce5e=function(_0x26bdbc){while(--_0x26bdbc){_0x3544dc['push'](_0x3544dc['shift']());}};_0x4fce5e(++_0x1fac28);}(_0x62a6,0x13f));var _0x662a=function(_0xdea41a,_0x552987){_0xdea41a=_0xdea41a-0x0;var _0x15d0d8=_0x62a6[_0xdea41a];return _0x15d0d8;};'use strict';var _=require(_0x662a('0x0'));var util=require(_0x662a('0x1'));var moment=require(_0x662a('0x2'));var BPromise=require(_0x662a('0x3'));var rs=require(_0x662a('0x4'));var fs=require('fs');var Redis=require(_0x662a('0x5'));var db=require(_0x662a('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x662a('0x7'))(_0x662a('0x8'));var config=require(_0x662a('0x9'));var jayson=require(_0x662a('0xa'));var client=jayson[_0x662a('0xb')][_0x662a('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x3aa950,_0x32412e,_0x1c59a6){return new BPromise(function(_0x260fa9,_0x5456a8){return client['request'](_0x3aa950,_0x1c59a6)[_0x662a('0xd')](function(_0x43986b){logger['info'](_0x662a('0xe'),_0x32412e,_0x662a('0xf'));logger[_0x662a('0x10')](_0x662a('0x11'),_0x32412e,'request\x20sent',JSON['stringify'](_0x43986b));if(_0x43986b[_0x662a('0x12')]){if(_0x43986b[_0x662a('0x12')][_0x662a('0x13')]===0x1f4){logger['error']('SquareRecording,\x20%s,\x20%s',_0x32412e,_0x43986b[_0x662a('0x12')][_0x662a('0x14')]);return _0x5456a8(_0x43986b[_0x662a('0x12')][_0x662a('0x14')]);}logger[_0x662a('0x12')](_0x662a('0xe'),_0x32412e,_0x43986b[_0x662a('0x12')][_0x662a('0x14')]);return _0x260fa9(_0x43986b[_0x662a('0x12')][_0x662a('0x14')]);}else{logger['info']('SquareRecording,\x20%s,\x20%s',_0x32412e,'request\x20sent');_0x260fa9(_0x43986b[_0x662a('0x15')][_0x662a('0x14')]);}})[_0x662a('0x16')](function(_0x1b31b4){logger[_0x662a('0x12')]('SquareRecording,\x20%s,\x20%s',_0x32412e,_0x1b31b4);_0x5456a8(_0x1b31b4);});});}exports['CreateSquareRecording']=function(_0x5086ec){var _0x45b5a7=this;return new Promise(function(_0x571c11,_0x54e737){return db[_0x662a('0x17')][_0x662a('0x18')](_0x5086ec[_0x662a('0x19')],{'raw':_0x5086ec[_0x662a('0x1a')]?_0x5086ec['options']['raw']===undefined?!![]:![]:!![]})[_0x662a('0xd')](function(_0x2424af){logger[_0x662a('0x1b')](_0x662a('0x1c'),_0x5086ec);logger[_0x662a('0x10')](_0x662a('0x1c'),_0x5086ec,JSON[_0x662a('0x1d')](_0x2424af));_0x571c11(_0x2424af);})[_0x662a('0x16')](function(_0x574ff8){logger['error'](_0x662a('0x1c'),_0x574ff8[_0x662a('0x14')],_0x5086ec);_0x54e737(_0x45b5a7['error'](0x1f4,_0x574ff8['message']));});});};