957286997caf355fbea3a2fb6c56c4de42b813df
[motion2.git] / server / api / migration / migration.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 _0x252f=['stringify','error','message','info','lodash','util','randomstring','ioredis','../../config/logger','rpc','../../config/environment','jayson/promise','client','then','Migration,\x20%s,\x20%s','debug','request\x20sent'];(function(_0x39bd7d,_0x23dff8){var _0x43d57d=function(_0x22c226){while(--_0x22c226){_0x39bd7d['push'](_0x39bd7d['shift']());}};_0x43d57d(++_0x23dff8);}(_0x252f,0xd0));var _0xf252=function(_0x22e9a1,_0x1d3a53){_0x22e9a1=_0x22e9a1-0x0;var _0x5bff12=_0x252f[_0x22e9a1];return _0x5bff12;};'use strict';var _=require(_0xf252('0x0'));var util=require(_0xf252('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xf252('0x2'));var fs=require('fs');var Redis=require(_0xf252('0x3'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xf252('0x4'))(_0xf252('0x5'));var config=require(_0xf252('0x6'));var jayson=require(_0xf252('0x7'));var client=jayson[_0xf252('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x3fad52,_0x18282c,_0x271d94){return new BPromise(function(_0xc8ae97,_0x25e8af){return client['request'](_0x3fad52,_0x271d94)[_0xf252('0x9')](function(_0x352951){logger['info'](_0xf252('0xa'),_0x18282c,'request\x20sent');logger[_0xf252('0xb')]('Migration,\x20%s,\x20%s,\x20%s',_0x18282c,_0xf252('0xc'),JSON[_0xf252('0xd')](_0x352951));if(_0x352951[_0xf252('0xe')]){if(_0x352951[_0xf252('0xe')]['code']===0x1f4){logger[_0xf252('0xe')](_0xf252('0xa'),_0x18282c,_0x352951[_0xf252('0xe')][_0xf252('0xf')]);return _0x25e8af(_0x352951[_0xf252('0xe')][_0xf252('0xf')]);}logger['error'](_0xf252('0xa'),_0x18282c,_0x352951[_0xf252('0xe')][_0xf252('0xf')]);return _0xc8ae97(_0x352951['error'][_0xf252('0xf')]);}else{logger[_0xf252('0x10')](_0xf252('0xa'),_0x18282c,_0xf252('0xc'));_0xc8ae97(_0x352951['result'][_0xf252('0xf')]);}})['catch'](function(_0x32a8e9){logger[_0xf252('0xe')](_0xf252('0xa'),_0x18282c,_0x32a8e9);_0x25e8af(_0x32a8e9);});});}