Built motion from commit (unavailable).|2.5.1
[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 _0x4a57=['rpc','client','http','info','SquareRecording,\x20%s,\x20%s','request\x20sent','debug','SquareRecording,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','SquareRecording','create','body','options','raw','then','CreateSquareRecording','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x4a57,0x18e));var _0x74a5=function(_0xf244e0,_0x20556c){_0xf244e0=_0xf244e0-0x0;var _0xe94095=_0x4a57[_0xf244e0];return _0xe94095;};'use strict';var _=require(_0x74a5('0x0'));var util=require(_0x74a5('0x1'));var moment=require(_0x74a5('0x2'));var BPromise=require('bluebird');var rs=require(_0x74a5('0x3'));var fs=require('fs');var Redis=require(_0x74a5('0x4'));var db=require(_0x74a5('0x5'))['db'];var utils=require(_0x74a5('0x6'));var logger=require(_0x74a5('0x7'))(_0x74a5('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x74a5('0x9')][_0x74a5('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x437805,_0x3d2fac,_0x4e21ff){return new BPromise(function(_0x5e65e8,_0x553ea8){return client['request'](_0x437805,_0x4e21ff)['then'](function(_0x5d218e){logger[_0x74a5('0xb')](_0x74a5('0xc'),_0x3d2fac,_0x74a5('0xd'));logger[_0x74a5('0xe')](_0x74a5('0xf'),_0x3d2fac,_0x74a5('0xd'),JSON[_0x74a5('0x10')](_0x5d218e));if(_0x5d218e[_0x74a5('0x11')]){if(_0x5d218e['error'][_0x74a5('0x12')]===0x1f4){logger[_0x74a5('0x11')](_0x74a5('0xc'),_0x3d2fac,_0x5d218e['error'][_0x74a5('0x13')]);return _0x553ea8(_0x5d218e['error'][_0x74a5('0x13')]);}logger[_0x74a5('0x11')]('SquareRecording,\x20%s,\x20%s',_0x3d2fac,_0x5d218e[_0x74a5('0x11')][_0x74a5('0x13')]);return _0x5e65e8(_0x5d218e['error'][_0x74a5('0x13')]);}else{logger[_0x74a5('0xb')](_0x74a5('0xc'),_0x3d2fac,_0x74a5('0xd'));_0x5e65e8(_0x5d218e[_0x74a5('0x14')]['message']);}})[_0x74a5('0x15')](function(_0xbcbe3){logger['error']('SquareRecording,\x20%s,\x20%s',_0x3d2fac,_0xbcbe3);_0x553ea8(_0xbcbe3);});});}exports['CreateSquareRecording']=function(_0x2fca07){var _0x128c14=this;return new Promise(function(_0x5b1748,_0x5449fb){return db[_0x74a5('0x16')][_0x74a5('0x17')](_0x2fca07[_0x74a5('0x18')],{'raw':_0x2fca07[_0x74a5('0x19')]?_0x2fca07[_0x74a5('0x19')][_0x74a5('0x1a')]===undefined?!![]:![]:!![]})[_0x74a5('0x1b')](function(_0x47b1e4){logger[_0x74a5('0xb')](_0x74a5('0x1c'),_0x2fca07);logger[_0x74a5('0xe')](_0x74a5('0x1c'),_0x2fca07,JSON[_0x74a5('0x10')](_0x47b1e4));_0x5b1748(_0x47b1e4);})[_0x74a5('0x15')](function(_0x1e1647){logger[_0x74a5('0x11')](_0x74a5('0x1c'),_0x1e1647[_0x74a5('0x13')],_0x2fca07);_0x5449fb(_0x128c14[_0x74a5('0x11')](0x1f4,_0x1e1647['message']));});});};