Built motion from commit 980b26c3.|2.6.29
[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 _0x6333=['message','info','catch','CreateSquareRecording','body','raw','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','debug','request\x20sent','stringify','error','code','SquareRecording,\x20%s,\x20%s'];(function(_0xd7d4c,_0x4d1b76){var _0x239a6e=function(_0x15c74b){while(--_0x15c74b){_0xd7d4c['push'](_0xd7d4c['shift']());}};_0x239a6e(++_0x4d1b76);}(_0x6333,0x83));var _0x3633=function(_0x3f4609,_0x4d0ff6){_0x3f4609=_0x3f4609-0x0;var _0x54ffe0=_0x6333[_0x3f4609];return _0x54ffe0;};'use strict';var _=require(_0x3633('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x3633('0x1'));var rs=require(_0x3633('0x2'));var fs=require('fs');var Redis=require(_0x3633('0x3'));var db=require(_0x3633('0x4'))['db'];var utils=require(_0x3633('0x5'));var logger=require(_0x3633('0x6'))(_0x3633('0x7'));var config=require(_0x3633('0x8'));var jayson=require(_0x3633('0x9'));var client=jayson['client'][_0x3633('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x484b91,_0x3e5cab,_0x428c1c){return new BPromise(function(_0x5513e7,_0x2e7ce1){return client[_0x3633('0xb')](_0x484b91,_0x428c1c)[_0x3633('0xc')](function(_0x5c62ca){logger['info']('SquareRecording,\x20%s,\x20%s',_0x3e5cab,'request\x20sent');logger[_0x3633('0xd')]('SquareRecording,\x20%s,\x20%s,\x20%s',_0x3e5cab,_0x3633('0xe'),JSON[_0x3633('0xf')](_0x5c62ca));if(_0x5c62ca[_0x3633('0x10')]){if(_0x5c62ca[_0x3633('0x10')][_0x3633('0x11')]===0x1f4){logger['error'](_0x3633('0x12'),_0x3e5cab,_0x5c62ca[_0x3633('0x10')][_0x3633('0x13')]);return _0x2e7ce1(_0x5c62ca[_0x3633('0x10')][_0x3633('0x13')]);}logger[_0x3633('0x10')](_0x3633('0x12'),_0x3e5cab,_0x5c62ca[_0x3633('0x10')][_0x3633('0x13')]);return _0x5513e7(_0x5c62ca['error'][_0x3633('0x13')]);}else{logger[_0x3633('0x14')](_0x3633('0x12'),_0x3e5cab,'request\x20sent');_0x5513e7(_0x5c62ca['result'][_0x3633('0x13')]);}})[_0x3633('0x15')](function(_0x5a2c09){logger[_0x3633('0x10')](_0x3633('0x12'),_0x3e5cab,_0x5a2c09);_0x2e7ce1(_0x5a2c09);});});}exports[_0x3633('0x16')]=function(_0xef236e){var _0x209607=this;return new Promise(function(_0x53a339,_0x4721df){return db['SquareRecording']['create'](_0xef236e[_0x3633('0x17')],{'raw':_0xef236e['options']?_0xef236e['options'][_0x3633('0x18')]===undefined?!![]:![]:!![]})[_0x3633('0xc')](function(_0x666969){logger[_0x3633('0x14')](_0x3633('0x16'),_0xef236e);logger[_0x3633('0xd')]('CreateSquareRecording',_0xef236e,JSON[_0x3633('0xf')](_0x666969));_0x53a339(_0x666969);})[_0x3633('0x15')](function(_0x17ad8b){logger[_0x3633('0x10')](_0x3633('0x16'),_0x17ad8b[_0x3633('0x13')],_0xef236e);_0x4721df(_0x209607[_0x3633('0x10')](0x1f4,_0x17ad8b[_0x3633('0x13')]));});});};