Built motion from commit 37e1ed56.|2.6.29
[motion2.git] / server / api / campaign / campaign.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 _0x871e=['GetCampaign','Campaign','findAll','options','raw','where','attributes','limit','include','map','model','then','lodash','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','info','Campaign,\x20%s,\x20%s','debug','Campaign,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch'];(function(_0x322008,_0x72f6cc){var _0xd2a42c=function(_0x374b63){while(--_0x374b63){_0x322008['push'](_0x322008['shift']());}};_0xd2a42c(++_0x72f6cc);}(_0x871e,0x1b0));var _0xe871=function(_0x37ce11,_0x58ed54){_0x37ce11=_0x37ce11-0x0;var _0x47340d=_0x871e[_0x37ce11];return _0x47340d;};'use strict';var _=require(_0xe871('0x0'));var util=require('util');var moment=require(_0xe871('0x1'));var BPromise=require(_0xe871('0x2'));var rs=require(_0xe871('0x3'));var fs=require('fs');var Redis=require(_0xe871('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xe871('0x5'));var logger=require(_0xe871('0x6'))(_0xe871('0x7'));var config=require(_0xe871('0x8'));var jayson=require(_0xe871('0x9'));var client=jayson[_0xe871('0xa')][_0xe871('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x13ed0e,_0x289308,_0x1d773f){return new BPromise(function(_0x4cf6af,_0x3bcc75){return client['request'](_0x13ed0e,_0x1d773f)['then'](function(_0x225f5b){logger[_0xe871('0xc')](_0xe871('0xd'),_0x289308,'request\x20sent');logger[_0xe871('0xe')](_0xe871('0xf'),_0x289308,_0xe871('0x10'),JSON[_0xe871('0x11')](_0x225f5b));if(_0x225f5b[_0xe871('0x12')]){if(_0x225f5b[_0xe871('0x12')][_0xe871('0x13')]===0x1f4){logger['error'](_0xe871('0xd'),_0x289308,_0x225f5b[_0xe871('0x12')][_0xe871('0x14')]);return _0x3bcc75(_0x225f5b[_0xe871('0x12')][_0xe871('0x14')]);}logger[_0xe871('0x12')](_0xe871('0xd'),_0x289308,_0x225f5b[_0xe871('0x12')][_0xe871('0x14')]);return _0x4cf6af(_0x225f5b['error'][_0xe871('0x14')]);}else{logger['info']('Campaign,\x20%s,\x20%s',_0x289308,_0xe871('0x10'));_0x4cf6af(_0x225f5b[_0xe871('0x15')][_0xe871('0x14')]);}})[_0xe871('0x16')](function(_0x2288c8){logger[_0xe871('0x12')](_0xe871('0xd'),_0x289308,_0x2288c8);_0x3bcc75(_0x2288c8);});});}exports[_0xe871('0x17')]=function(_0x11ad56){var _0x4d7c98=this;return new Promise(function(_0x31319f,_0x57f15d){return db[_0xe871('0x18')][_0xe871('0x19')]({'raw':_0x11ad56['options']?_0x11ad56[_0xe871('0x1a')][_0xe871('0x1b')]===undefined?!![]:![]:!![],'where':_0x11ad56[_0xe871('0x1a')]?_0x11ad56[_0xe871('0x1a')][_0xe871('0x1c')]||null:null,'attributes':_0x11ad56[_0xe871('0x1a')]?_0x11ad56[_0xe871('0x1a')][_0xe871('0x1d')]||null:null,'limit':_0x11ad56[_0xe871('0x1a')]?_0x11ad56[_0xe871('0x1a')][_0xe871('0x1e')]||null:null,'include':_0x11ad56[_0xe871('0x1a')]?_0x11ad56[_0xe871('0x1a')][_0xe871('0x1f')]?_[_0xe871('0x20')](_0x11ad56[_0xe871('0x1a')][_0xe871('0x1f')],function(_0x45ca0d){return{'model':db[_0x45ca0d[_0xe871('0x21')]],'as':_0x45ca0d['as'],'attributes':_0x45ca0d[_0xe871('0x1d')],'include':_0x45ca0d[_0xe871('0x1f')]?_[_0xe871('0x20')](_0x45ca0d[_0xe871('0x1f')],function(_0x416589){return{'model':db[_0x416589[_0xe871('0x21')]],'as':_0x416589['as'],'attributes':_0x416589[_0xe871('0x1d')],'include':_0x416589['include']?_['map'](_0x416589['include'],function(_0x469b45){return{'model':db[_0x469b45[_0xe871('0x21')]],'as':_0x469b45['as'],'attributes':_0x469b45[_0xe871('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xe871('0x22')](function(_0x5dfb27){logger[_0xe871('0xc')]('GetCampaign',_0x11ad56);logger['debug']('GetCampaign',_0x11ad56,JSON[_0xe871('0x11')](_0x5dfb27));_0x31319f(_0x5dfb27);})[_0xe871('0x16')](function(_0x2bfab3){logger[_0xe871('0x12')](_0xe871('0x17'),_0x2bfab3[_0xe871('0x14')],_0x11ad56);_0x57f15d(_0x4d7c98[_0xe871('0x12')](0x1f4,_0x2bfab3[_0xe871('0x14')]));});});};