Built motion from commit 9d0783e6.|2.6.13
[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 _0xb922=['jayson/promise','client','http','request','SquareRecording,\x20%s,\x20%s','request\x20sent','debug','SquareRecording,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','CreateSquareRecording','SquareRecording','create','body','raw','then','info','lodash','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment'];(function(_0x14a4af,_0x125b3){var _0x4085bc=function(_0x1ea6d2){while(--_0x1ea6d2){_0x14a4af['push'](_0x14a4af['shift']());}};_0x4085bc(++_0x125b3);}(_0xb922,0x1c7));var _0x2b92=function(_0x4490f4,_0x150e06){_0x4490f4=_0x4490f4-0x0;var _0x3e2a76=_0xb922[_0x4490f4];return _0x3e2a76;};'use strict';var _=require(_0x2b92('0x0'));var util=require(_0x2b92('0x1'));var moment=require(_0x2b92('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x2b92('0x3'));var db=require(_0x2b92('0x4'))['db'];var utils=require(_0x2b92('0x5'));var logger=require(_0x2b92('0x6'))(_0x2b92('0x7'));var config=require(_0x2b92('0x8'));var jayson=require(_0x2b92('0x9'));var client=jayson[_0x2b92('0xa')][_0x2b92('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x1334c6,_0xec936f,_0x3777c8){return new BPromise(function(_0x4602de,_0x101f81){return client[_0x2b92('0xc')](_0x1334c6,_0x3777c8)['then'](function(_0x3b67ef){logger['info'](_0x2b92('0xd'),_0xec936f,_0x2b92('0xe'));logger[_0x2b92('0xf')](_0x2b92('0x10'),_0xec936f,_0x2b92('0xe'),JSON[_0x2b92('0x11')](_0x3b67ef));if(_0x3b67ef[_0x2b92('0x12')]){if(_0x3b67ef['error']['code']===0x1f4){logger[_0x2b92('0x12')](_0x2b92('0xd'),_0xec936f,_0x3b67ef['error'][_0x2b92('0x13')]);return _0x101f81(_0x3b67ef[_0x2b92('0x12')][_0x2b92('0x13')]);}logger[_0x2b92('0x12')](_0x2b92('0xd'),_0xec936f,_0x3b67ef[_0x2b92('0x12')][_0x2b92('0x13')]);return _0x4602de(_0x3b67ef[_0x2b92('0x12')]['message']);}else{logger['info'](_0x2b92('0xd'),_0xec936f,_0x2b92('0xe'));_0x4602de(_0x3b67ef[_0x2b92('0x14')][_0x2b92('0x13')]);}})[_0x2b92('0x15')](function(_0x40458d){logger['error'](_0x2b92('0xd'),_0xec936f,_0x40458d);_0x101f81(_0x40458d);});});}exports[_0x2b92('0x16')]=function(_0x2ef408){var _0x213d51=this;return new Promise(function(_0xad5daa,_0x5dd37c){return db[_0x2b92('0x17')][_0x2b92('0x18')](_0x2ef408[_0x2b92('0x19')],{'raw':_0x2ef408['options']?_0x2ef408['options'][_0x2b92('0x1a')]===undefined?!![]:![]:!![]})[_0x2b92('0x1b')](function(_0x4fb94b){logger[_0x2b92('0x1c')](_0x2b92('0x16'),_0x2ef408);logger[_0x2b92('0xf')](_0x2b92('0x16'),_0x2ef408,JSON['stringify'](_0x4fb94b));_0xad5daa(_0x4fb94b);})['catch'](function(_0x1ab33b){logger[_0x2b92('0x12')](_0x2b92('0x16'),_0x1ab33b[_0x2b92('0x13')],_0x2ef408);_0x5dd37c(_0x213d51[_0x2b92('0x12')](0x1f4,_0x1ab33b[_0x2b92('0x13')]));});});};