f59941f2c98d320530c12febbb54715531ff8674
[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 _0x106e=['message','result','catch','CreateSquareRecording','SquareRecording','create','body','options','lodash','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','http','request','then','info','request\x20sent','debug','stringify','error','code','SquareRecording,\x20%s,\x20%s'];(function(_0x559e43,_0x4edb41){var _0xef4da2=function(_0x5117cb){while(--_0x5117cb){_0x559e43['push'](_0x559e43['shift']());}};_0xef4da2(++_0x4edb41);}(_0x106e,0x182));var _0xe106=function(_0x50216d,_0x2d367e){_0x50216d=_0x50216d-0x0;var _0x3e2ff5=_0x106e[_0x50216d];return _0x3e2ff5;};'use strict';var _=require(_0xe106('0x0'));var util=require(_0xe106('0x1'));var moment=require(_0xe106('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xe106('0x3'));var db=require(_0xe106('0x4'))['db'];var utils=require(_0xe106('0x5'));var logger=require(_0xe106('0x6'))('rpc');var config=require(_0xe106('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xe106('0x8')][_0xe106('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x118699,_0x26a846,_0xb32567){return new BPromise(function(_0xa614b5,_0x5475e0){return client[_0xe106('0xa')](_0x118699,_0xb32567)[_0xe106('0xb')](function(_0xe54c88){logger[_0xe106('0xc')]('SquareRecording,\x20%s,\x20%s',_0x26a846,_0xe106('0xd'));logger[_0xe106('0xe')]('SquareRecording,\x20%s,\x20%s,\x20%s',_0x26a846,_0xe106('0xd'),JSON[_0xe106('0xf')](_0xe54c88));if(_0xe54c88[_0xe106('0x10')]){if(_0xe54c88['error'][_0xe106('0x11')]===0x1f4){logger['error'](_0xe106('0x12'),_0x26a846,_0xe54c88['error'][_0xe106('0x13')]);return _0x5475e0(_0xe54c88[_0xe106('0x10')]['message']);}logger[_0xe106('0x10')]('SquareRecording,\x20%s,\x20%s',_0x26a846,_0xe54c88[_0xe106('0x10')]['message']);return _0xa614b5(_0xe54c88['error'][_0xe106('0x13')]);}else{logger[_0xe106('0xc')](_0xe106('0x12'),_0x26a846,_0xe106('0xd'));_0xa614b5(_0xe54c88[_0xe106('0x14')][_0xe106('0x13')]);}})[_0xe106('0x15')](function(_0x126a4b){logger[_0xe106('0x10')]('SquareRecording,\x20%s,\x20%s',_0x26a846,_0x126a4b);_0x5475e0(_0x126a4b);});});}exports[_0xe106('0x16')]=function(_0x5e3d09){var _0x316b07=this;return new Promise(function(_0x301c15,_0x230cd3){return db[_0xe106('0x17')][_0xe106('0x18')](_0x5e3d09[_0xe106('0x19')],{'raw':_0x5e3d09[_0xe106('0x1a')]?_0x5e3d09[_0xe106('0x1a')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x24c7ee){logger['info'](_0xe106('0x16'),_0x5e3d09);logger[_0xe106('0xe')](_0xe106('0x16'),_0x5e3d09,JSON['stringify'](_0x24c7ee));_0x301c15(_0x24c7ee);})[_0xe106('0x15')](function(_0x5166c0){logger['error'](_0xe106('0x16'),_0x5166c0[_0xe106('0x13')],_0x5e3d09);_0x230cd3(_0x316b07['error'](0x1f4,_0x5166c0[_0xe106('0x13')]));});});};