Built motion from commit 639a1a7f.|2.6.19
[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 _0xf401=['util','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','request','then','request\x20sent','debug','stringify','error','SquareRecording,\x20%s,\x20%s','message','info','result','CreateSquareRecording','SquareRecording','create','body','options','catch'];(function(_0x595b9b,_0xa58ff){var _0x3be4c6=function(_0x324f94){while(--_0x324f94){_0x595b9b['push'](_0x595b9b['shift']());}};_0x3be4c6(++_0xa58ff);}(_0xf401,0x1db));var _0x1f40=function(_0x579859,_0x4e9af7){_0x579859=_0x579859-0x0;var _0x49565f=_0xf401[_0x579859];return _0x49565f;};'use strict';var _=require('lodash');var util=require(_0x1f40('0x0'));var moment=require('moment');var BPromise=require(_0x1f40('0x1'));var rs=require(_0x1f40('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x1f40('0x3'))['db'];var utils=require(_0x1f40('0x4'));var logger=require(_0x1f40('0x5'))(_0x1f40('0x6'));var config=require(_0x1f40('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x1f40('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x63f79b,_0x35fc64,_0x334d3d){return new BPromise(function(_0x56ee6e,_0x812af6){return client[_0x1f40('0x9')](_0x63f79b,_0x334d3d)[_0x1f40('0xa')](function(_0x58be1b){logger['info']('SquareRecording,\x20%s,\x20%s',_0x35fc64,_0x1f40('0xb'));logger[_0x1f40('0xc')]('SquareRecording,\x20%s,\x20%s,\x20%s',_0x35fc64,'request\x20sent',JSON[_0x1f40('0xd')](_0x58be1b));if(_0x58be1b[_0x1f40('0xe')]){if(_0x58be1b['error']['code']===0x1f4){logger[_0x1f40('0xe')](_0x1f40('0xf'),_0x35fc64,_0x58be1b['error'][_0x1f40('0x10')]);return _0x812af6(_0x58be1b[_0x1f40('0xe')][_0x1f40('0x10')]);}logger[_0x1f40('0xe')]('SquareRecording,\x20%s,\x20%s',_0x35fc64,_0x58be1b['error'][_0x1f40('0x10')]);return _0x56ee6e(_0x58be1b['error']['message']);}else{logger[_0x1f40('0x11')]('SquareRecording,\x20%s,\x20%s',_0x35fc64,_0x1f40('0xb'));_0x56ee6e(_0x58be1b[_0x1f40('0x12')]['message']);}})['catch'](function(_0x339556){logger[_0x1f40('0xe')](_0x1f40('0xf'),_0x35fc64,_0x339556);_0x812af6(_0x339556);});});}exports[_0x1f40('0x13')]=function(_0x5912dc){var _0x338fae=this;return new Promise(function(_0x10d1f7,_0x1f4cf0){return db[_0x1f40('0x14')][_0x1f40('0x15')](_0x5912dc[_0x1f40('0x16')],{'raw':_0x5912dc[_0x1f40('0x17')]?_0x5912dc[_0x1f40('0x17')]['raw']===undefined?!![]:![]:!![]})[_0x1f40('0xa')](function(_0x4729c9){logger[_0x1f40('0x11')](_0x1f40('0x13'),_0x5912dc);logger[_0x1f40('0xc')](_0x1f40('0x13'),_0x5912dc,JSON[_0x1f40('0xd')](_0x4729c9));_0x10d1f7(_0x4729c9);})[_0x1f40('0x18')](function(_0x3f37ea){logger['error'](_0x1f40('0x13'),_0x3f37ea[_0x1f40('0x10')],_0x5912dc);_0x1f4cf0(_0x338fae[_0x1f40('0xe')](0x1f4,_0x3f37ea[_0x1f40('0x10')]));});});};