Built motion from commit 753c950e.|2.5.42
[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 _0x3233=['lodash','util','randomstring','ioredis','../../config/utils','../../config/logger','rpc','client','http','then','info','SquareRecording,\x20%s,\x20%s','request\x20sent','SquareRecording,\x20%s,\x20%s,\x20%s','error','code','result','CreateSquareRecording','create','options','raw','debug','catch','message'];(function(_0x2de4c3,_0x646aad){var _0xc324fd=function(_0x578822){while(--_0x578822){_0x2de4c3['push'](_0x2de4c3['shift']());}};_0xc324fd(++_0x646aad);}(_0x3233,0x198));var _0x3323=function(_0xc7a6e8,_0x7c3b71){_0xc7a6e8=_0xc7a6e8-0x0;var _0x4d3abd=_0x3233[_0xc7a6e8];return _0x4d3abd;};'use strict';var _=require(_0x3323('0x0'));var util=require(_0x3323('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x3323('0x2'));var fs=require('fs');var Redis=require(_0x3323('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x3323('0x4'));var logger=require(_0x3323('0x5'))(_0x3323('0x6'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x3323('0x7')][_0x3323('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x3c85f8,_0xd60e41,_0x45b9b5){return new BPromise(function(_0x1f6d4c,_0x50042a){return client['request'](_0x3c85f8,_0x45b9b5)[_0x3323('0x9')](function(_0x2631fc){logger[_0x3323('0xa')](_0x3323('0xb'),_0xd60e41,_0x3323('0xc'));logger['debug'](_0x3323('0xd'),_0xd60e41,'request\x20sent',JSON['stringify'](_0x2631fc));if(_0x2631fc[_0x3323('0xe')]){if(_0x2631fc[_0x3323('0xe')][_0x3323('0xf')]===0x1f4){logger[_0x3323('0xe')](_0x3323('0xb'),_0xd60e41,_0x2631fc[_0x3323('0xe')]['message']);return _0x50042a(_0x2631fc['error']['message']);}logger[_0x3323('0xe')](_0x3323('0xb'),_0xd60e41,_0x2631fc['error']['message']);return _0x1f6d4c(_0x2631fc[_0x3323('0xe')]['message']);}else{logger[_0x3323('0xa')](_0x3323('0xb'),_0xd60e41,_0x3323('0xc'));_0x1f6d4c(_0x2631fc[_0x3323('0x10')]['message']);}})['catch'](function(_0xdead45){logger[_0x3323('0xe')](_0x3323('0xb'),_0xd60e41,_0xdead45);_0x50042a(_0xdead45);});});}exports[_0x3323('0x11')]=function(_0xdc5d9a){var _0xd44c77=this;return new Promise(function(_0x204fc5,_0x170a40){return db['SquareRecording'][_0x3323('0x12')](_0xdc5d9a['body'],{'raw':_0xdc5d9a[_0x3323('0x13')]?_0xdc5d9a[_0x3323('0x13')][_0x3323('0x14')]===undefined?!![]:![]:!![]})[_0x3323('0x9')](function(_0x593103){logger[_0x3323('0xa')](_0x3323('0x11'),_0xdc5d9a);logger[_0x3323('0x15')](_0x3323('0x11'),_0xdc5d9a,JSON['stringify'](_0x593103));_0x204fc5(_0x593103);})[_0x3323('0x16')](function(_0x43389b){logger['error'](_0x3323('0x11'),_0x43389b[_0x3323('0x17')],_0xdc5d9a);_0x170a40(_0xd44c77[_0x3323('0xe')](0x1f4,_0x43389b[_0x3323('0x17')]));});});};