d02f709f564d720853c95d6576363e77e2386013
[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 _0xe1a1=['../../config/environment','jayson/promise','client','http','request','then','request\x20sent','debug','Migration,\x20%s,\x20%s,\x20%s','stringify','error','Migration,\x20%s,\x20%s','message','result','catch','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x40e17a,_0x170067){var _0x4b15ce=function(_0x5d128d){while(--_0x5d128d){_0x40e17a['push'](_0x40e17a['shift']());}};_0x4b15ce(++_0x170067);}(_0xe1a1,0x14a));var _0x1e1a=function(_0x49b207,_0x408ade){_0x49b207=_0x49b207-0x0;var _0x2dc8fa=_0xe1a1[_0x49b207];return _0x2dc8fa;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x1e1a('0x0'));var BPromise=require(_0x1e1a('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x1e1a('0x2'))['db'];var utils=require(_0x1e1a('0x3'));var logger=require(_0x1e1a('0x4'))(_0x1e1a('0x5'));var config=require(_0x1e1a('0x6'));var jayson=require(_0x1e1a('0x7'));var client=jayson[_0x1e1a('0x8')][_0x1e1a('0x9')]({'port':0x232a});function respondWithRpcPromise(_0xf1d3f5,_0x582e55,_0xd6f52b){return new BPromise(function(_0x5800b8,_0x49db37){return client[_0x1e1a('0xa')](_0xf1d3f5,_0xd6f52b)[_0x1e1a('0xb')](function(_0x2a2302){logger['info']('Migration,\x20%s,\x20%s',_0x582e55,_0x1e1a('0xc'));logger[_0x1e1a('0xd')](_0x1e1a('0xe'),_0x582e55,_0x1e1a('0xc'),JSON[_0x1e1a('0xf')](_0x2a2302));if(_0x2a2302[_0x1e1a('0x10')]){if(_0x2a2302[_0x1e1a('0x10')]['code']===0x1f4){logger[_0x1e1a('0x10')](_0x1e1a('0x11'),_0x582e55,_0x2a2302[_0x1e1a('0x10')]['message']);return _0x49db37(_0x2a2302[_0x1e1a('0x10')][_0x1e1a('0x12')]);}logger['error'](_0x1e1a('0x11'),_0x582e55,_0x2a2302[_0x1e1a('0x10')][_0x1e1a('0x12')]);return _0x5800b8(_0x2a2302['error'][_0x1e1a('0x12')]);}else{logger['info'](_0x1e1a('0x11'),_0x582e55,_0x1e1a('0xc'));_0x5800b8(_0x2a2302[_0x1e1a('0x13')][_0x1e1a('0x12')]);}})[_0x1e1a('0x14')](function(_0x15fd49){logger[_0x1e1a('0x10')]('Migration,\x20%s,\x20%s',_0x582e55,_0x15fd49);_0x49db37(_0x15fd49);});});}