Built motion from commit e1760111.|2.6.18
[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 _0xf378=['info','SquareRecording,\x20%s,\x20%s','request\x20sent','error','code','message','result','catch','CreateSquareRecording','SquareRecording','create','body','options','raw','debug','stringify','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/environment','jayson/promise','client','http','request','then'];(function(_0x8beeeb,_0x373d75){var _0x568897=function(_0x4f68f8){while(--_0x4f68f8){_0x8beeeb['push'](_0x8beeeb['shift']());}};_0x568897(++_0x373d75);}(_0xf378,0xd4));var _0x8f37=function(_0x465a0c,_0x19d4d5){_0x465a0c=_0x465a0c-0x0;var _0x1e202e=_0xf378[_0x465a0c];return _0x1e202e;};'use strict';var _=require('lodash');var util=require(_0x8f37('0x0'));var moment=require(_0x8f37('0x1'));var BPromise=require(_0x8f37('0x2'));var rs=require(_0x8f37('0x3'));var fs=require('fs');var Redis=require(_0x8f37('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x8f37('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0x8f37('0x6'));var jayson=require(_0x8f37('0x7'));var client=jayson[_0x8f37('0x8')][_0x8f37('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3118f7,_0x2e11ec,_0x585c73){return new BPromise(function(_0x276766,_0x58a953){return client[_0x8f37('0xa')](_0x3118f7,_0x585c73)[_0x8f37('0xb')](function(_0x3a28f2){logger[_0x8f37('0xc')](_0x8f37('0xd'),_0x2e11ec,_0x8f37('0xe'));logger['debug']('SquareRecording,\x20%s,\x20%s,\x20%s',_0x2e11ec,_0x8f37('0xe'),JSON['stringify'](_0x3a28f2));if(_0x3a28f2['error']){if(_0x3a28f2[_0x8f37('0xf')][_0x8f37('0x10')]===0x1f4){logger[_0x8f37('0xf')]('SquareRecording,\x20%s,\x20%s',_0x2e11ec,_0x3a28f2['error'][_0x8f37('0x11')]);return _0x58a953(_0x3a28f2[_0x8f37('0xf')][_0x8f37('0x11')]);}logger['error']('SquareRecording,\x20%s,\x20%s',_0x2e11ec,_0x3a28f2[_0x8f37('0xf')]['message']);return _0x276766(_0x3a28f2[_0x8f37('0xf')]['message']);}else{logger[_0x8f37('0xc')]('SquareRecording,\x20%s,\x20%s',_0x2e11ec,'request\x20sent');_0x276766(_0x3a28f2[_0x8f37('0x12')][_0x8f37('0x11')]);}})[_0x8f37('0x13')](function(_0x3cff7c){logger[_0x8f37('0xf')](_0x8f37('0xd'),_0x2e11ec,_0x3cff7c);_0x58a953(_0x3cff7c);});});}exports[_0x8f37('0x14')]=function(_0x2eccaf){var _0x351c2b=this;return new Promise(function(_0x5d7536,_0x20c1e2){return db[_0x8f37('0x15')][_0x8f37('0x16')](_0x2eccaf[_0x8f37('0x17')],{'raw':_0x2eccaf['options']?_0x2eccaf[_0x8f37('0x18')][_0x8f37('0x19')]===undefined?!![]:![]:!![]})['then'](function(_0x8062){logger[_0x8f37('0xc')]('CreateSquareRecording',_0x2eccaf);logger[_0x8f37('0x1a')](_0x8f37('0x14'),_0x2eccaf,JSON[_0x8f37('0x1b')](_0x8062));_0x5d7536(_0x8062);})['catch'](function(_0x25d315){logger['error'](_0x8f37('0x14'),_0x25d315[_0x8f37('0x11')],_0x2eccaf);_0x20c1e2(_0x351c2b['error'](0x1f4,_0x25d315[_0x8f37('0x11')]));});});};