Built motion from commit efa66e19.|2.6.22
[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 _0x8baf=['jayson/promise','client','http','info','SquareRecording,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','SquareRecording','create','body','options','then','CreateSquareRecording','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment'];(function(_0x55e2a8,_0x3baf04){var _0x28e07a=function(_0x131abe){while(--_0x131abe){_0x55e2a8['push'](_0x55e2a8['shift']());}};_0x28e07a(++_0x3baf04);}(_0x8baf,0xd7));var _0xf8ba=function(_0x74741a,_0x18c22f){_0x74741a=_0x74741a-0x0;var _0x28d8d6=_0x8baf[_0x74741a];return _0x28d8d6;};'use strict';var _=require(_0xf8ba('0x0'));var util=require(_0xf8ba('0x1'));var moment=require(_0xf8ba('0x2'));var BPromise=require('bluebird');var rs=require(_0xf8ba('0x3'));var fs=require('fs');var Redis=require(_0xf8ba('0x4'));var db=require(_0xf8ba('0x5'))['db'];var utils=require(_0xf8ba('0x6'));var logger=require(_0xf8ba('0x7'))('rpc');var config=require(_0xf8ba('0x8'));var jayson=require(_0xf8ba('0x9'));var client=jayson[_0xf8ba('0xa')][_0xf8ba('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x34c07a,_0x492d2a,_0x323b8c){return new BPromise(function(_0x25cb04,_0x15c7ed){return client['request'](_0x34c07a,_0x323b8c)['then'](function(_0x258d3a){logger[_0xf8ba('0xc')](_0xf8ba('0xd'),_0x492d2a,_0xf8ba('0xe'));logger[_0xf8ba('0xf')]('SquareRecording,\x20%s,\x20%s,\x20%s',_0x492d2a,'request\x20sent',JSON[_0xf8ba('0x10')](_0x258d3a));if(_0x258d3a[_0xf8ba('0x11')]){if(_0x258d3a[_0xf8ba('0x11')][_0xf8ba('0x12')]===0x1f4){logger[_0xf8ba('0x11')](_0xf8ba('0xd'),_0x492d2a,_0x258d3a[_0xf8ba('0x11')]['message']);return _0x15c7ed(_0x258d3a[_0xf8ba('0x11')]['message']);}logger[_0xf8ba('0x11')](_0xf8ba('0xd'),_0x492d2a,_0x258d3a[_0xf8ba('0x11')][_0xf8ba('0x13')]);return _0x25cb04(_0x258d3a[_0xf8ba('0x11')][_0xf8ba('0x13')]);}else{logger[_0xf8ba('0xc')](_0xf8ba('0xd'),_0x492d2a,_0xf8ba('0xe'));_0x25cb04(_0x258d3a[_0xf8ba('0x14')][_0xf8ba('0x13')]);}})[_0xf8ba('0x15')](function(_0x287558){logger[_0xf8ba('0x11')](_0xf8ba('0xd'),_0x492d2a,_0x287558);_0x15c7ed(_0x287558);});});}exports['CreateSquareRecording']=function(_0x595729){var _0x315e37=this;return new Promise(function(_0x2edea8,_0x56699f){return db[_0xf8ba('0x16')][_0xf8ba('0x17')](_0x595729[_0xf8ba('0x18')],{'raw':_0x595729[_0xf8ba('0x19')]?_0x595729['options']['raw']===undefined?!![]:![]:!![]})[_0xf8ba('0x1a')](function(_0x2b650e){logger[_0xf8ba('0xc')](_0xf8ba('0x1b'),_0x595729);logger['debug'](_0xf8ba('0x1b'),_0x595729,JSON[_0xf8ba('0x10')](_0x2b650e));_0x2edea8(_0x2b650e);})['catch'](function(_0xbee9bd){logger['error'](_0xf8ba('0x1b'),_0xbee9bd['message'],_0x595729);_0x56699f(_0x315e37[_0xf8ba('0x11')](0x1f4,_0xbee9bd[_0xf8ba('0x13')]));});});};