Built motion from commit 85328c08.|2.5.50
[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 _0x4bb5=['create','options','raw','CreateSquareRecording','util','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','then','info','SquareRecording,\x20%s,\x20%s','SquareRecording,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','SquareRecording'];(function(_0x19e35c,_0x29cd1e){var _0x3e1fe8=function(_0x17258b){while(--_0x17258b){_0x19e35c['push'](_0x19e35c['shift']());}};_0x3e1fe8(++_0x29cd1e);}(_0x4bb5,0x162));var _0x54bb=function(_0x11ed16,_0x3b87f0){_0x11ed16=_0x11ed16-0x0;var _0x5c6399=_0x4bb5[_0x11ed16];return _0x5c6399;};'use strict';var _=require('lodash');var util=require(_0x54bb('0x0'));var moment=require(_0x54bb('0x1'));var BPromise=require(_0x54bb('0x2'));var rs=require(_0x54bb('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x54bb('0x4'));var logger=require(_0x54bb('0x5'))(_0x54bb('0x6'));var config=require(_0x54bb('0x7'));var jayson=require(_0x54bb('0x8'));var client=jayson[_0x54bb('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x359fcf,_0x2f21ce,_0x5985a2){return new BPromise(function(_0x161868,_0x4f986a){return client['request'](_0x359fcf,_0x5985a2)[_0x54bb('0xa')](function(_0x4d8afc){logger[_0x54bb('0xb')](_0x54bb('0xc'),_0x2f21ce,'request\x20sent');logger['debug'](_0x54bb('0xd'),_0x2f21ce,_0x54bb('0xe'),JSON[_0x54bb('0xf')](_0x4d8afc));if(_0x4d8afc[_0x54bb('0x10')]){if(_0x4d8afc[_0x54bb('0x10')]['code']===0x1f4){logger[_0x54bb('0x10')](_0x54bb('0xc'),_0x2f21ce,_0x4d8afc['error'][_0x54bb('0x11')]);return _0x4f986a(_0x4d8afc[_0x54bb('0x10')][_0x54bb('0x11')]);}logger[_0x54bb('0x10')]('SquareRecording,\x20%s,\x20%s',_0x2f21ce,_0x4d8afc[_0x54bb('0x10')]['message']);return _0x161868(_0x4d8afc['error'][_0x54bb('0x11')]);}else{logger['info']('SquareRecording,\x20%s,\x20%s',_0x2f21ce,_0x54bb('0xe'));_0x161868(_0x4d8afc[_0x54bb('0x12')][_0x54bb('0x11')]);}})[_0x54bb('0x13')](function(_0x5580d3){logger[_0x54bb('0x10')](_0x54bb('0xc'),_0x2f21ce,_0x5580d3);_0x4f986a(_0x5580d3);});});}exports['CreateSquareRecording']=function(_0x31c4da){var _0x4f31e6=this;return new Promise(function(_0x7b7585,_0x5d2148){return db[_0x54bb('0x14')][_0x54bb('0x15')](_0x31c4da['body'],{'raw':_0x31c4da[_0x54bb('0x16')]?_0x31c4da[_0x54bb('0x16')][_0x54bb('0x17')]===undefined?!![]:![]:!![]})[_0x54bb('0xa')](function(_0x38e9de){logger[_0x54bb('0xb')]('CreateSquareRecording',_0x31c4da);logger['debug'](_0x54bb('0x18'),_0x31c4da,JSON['stringify'](_0x38e9de));_0x7b7585(_0x38e9de);})[_0x54bb('0x13')](function(_0x4f5aa0){logger[_0x54bb('0x10')]('CreateSquareRecording',_0x4f5aa0[_0x54bb('0x11')],_0x31c4da);_0x5d2148(_0x4f31e6[_0x54bb('0x10')](0x1f4,_0x4f5aa0['message']));});});};