d82fefa9a39799636bfd7a94957c3511948d8f24
[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 _0x85cf=['jayson/promise','client','request','info','debug','request\x20sent','stringify','error','code','Migration,\x20%s,\x20%s','message','result','catch','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x53f6f2,_0x364bcf){var _0x14c5d3=function(_0x9b343a){while(--_0x9b343a){_0x53f6f2['push'](_0x53f6f2['shift']());}};_0x14c5d3(++_0x364bcf);}(_0x85cf,0x76));var _0xf85c=function(_0x1b713a,_0x252e46){_0x1b713a=_0x1b713a-0x0;var _0x1cbda5=_0x85cf[_0x1b713a];return _0x1cbda5;};'use strict';var _=require('lodash');var util=require(_0xf85c('0x0'));var moment=require(_0xf85c('0x1'));var BPromise=require(_0xf85c('0x2'));var rs=require(_0xf85c('0x3'));var fs=require('fs');var Redis=require(_0xf85c('0x4'));var db=require(_0xf85c('0x5'))['db'];var utils=require(_0xf85c('0x6'));var logger=require(_0xf85c('0x7'))('rpc');var config=require('../../config/environment');var jayson=require(_0xf85c('0x8'));var client=jayson[_0xf85c('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x386a60,_0x41d08d,_0xe1be83){return new BPromise(function(_0x1bebcf,_0x1857d9){return client[_0xf85c('0xa')](_0x386a60,_0xe1be83)['then'](function(_0x25aa6e){logger[_0xf85c('0xb')]('Migration,\x20%s,\x20%s',_0x41d08d,'request\x20sent');logger[_0xf85c('0xc')]('Migration,\x20%s,\x20%s,\x20%s',_0x41d08d,_0xf85c('0xd'),JSON[_0xf85c('0xe')](_0x25aa6e));if(_0x25aa6e[_0xf85c('0xf')]){if(_0x25aa6e['error'][_0xf85c('0x10')]===0x1f4){logger[_0xf85c('0xf')](_0xf85c('0x11'),_0x41d08d,_0x25aa6e[_0xf85c('0xf')]['message']);return _0x1857d9(_0x25aa6e[_0xf85c('0xf')][_0xf85c('0x12')]);}logger[_0xf85c('0xf')](_0xf85c('0x11'),_0x41d08d,_0x25aa6e['error'][_0xf85c('0x12')]);return _0x1bebcf(_0x25aa6e['error'][_0xf85c('0x12')]);}else{logger['info'](_0xf85c('0x11'),_0x41d08d,'request\x20sent');_0x1bebcf(_0x25aa6e[_0xf85c('0x13')]['message']);}})[_0xf85c('0x14')](function(_0x30b768){logger[_0xf85c('0xf')](_0xf85c('0x11'),_0x41d08d,_0x30b768);_0x1857d9(_0x30b768);});});}