Built motion from commit ba71417a.|2.6.28
[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 _0xb248=['code','message','catch','GetCampaign','findAll','options','raw','where','include','map','model','attributes','lodash','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','request','then','info','Campaign,\x20%s,\x20%s','request\x20sent','debug','Campaign,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x230790,_0x3f9d72){var _0x1d8d80=function(_0x4e0968){while(--_0x4e0968){_0x230790['push'](_0x230790['shift']());}};_0x1d8d80(++_0x3f9d72);}(_0xb248,0xc6));var _0x8b24=function(_0x2d7f0e,_0x3e6fbd){_0x2d7f0e=_0x2d7f0e-0x0;var _0x110b07=_0xb248[_0x2d7f0e];return _0x110b07;};'use strict';var _=require(_0x8b24('0x0'));var util=require('util');var moment=require(_0x8b24('0x1'));var BPromise=require(_0x8b24('0x2'));var rs=require(_0x8b24('0x3'));var fs=require('fs');var Redis=require(_0x8b24('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x8b24('0x5'));var logger=require(_0x8b24('0x6'))('rpc');var config=require(_0x8b24('0x7'));var jayson=require(_0x8b24('0x8'));var client=jayson['client'][_0x8b24('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x4705e0,_0x588ca8,_0x3198a2){return new BPromise(function(_0x51bbad,_0x43b851){return client[_0x8b24('0xa')](_0x4705e0,_0x3198a2)[_0x8b24('0xb')](function(_0x4ad0db){logger[_0x8b24('0xc')](_0x8b24('0xd'),_0x588ca8,_0x8b24('0xe'));logger[_0x8b24('0xf')](_0x8b24('0x10'),_0x588ca8,_0x8b24('0xe'),JSON[_0x8b24('0x11')](_0x4ad0db));if(_0x4ad0db[_0x8b24('0x12')]){if(_0x4ad0db[_0x8b24('0x12')][_0x8b24('0x13')]===0x1f4){logger[_0x8b24('0x12')](_0x8b24('0xd'),_0x588ca8,_0x4ad0db[_0x8b24('0x12')][_0x8b24('0x14')]);return _0x43b851(_0x4ad0db['error']['message']);}logger[_0x8b24('0x12')](_0x8b24('0xd'),_0x588ca8,_0x4ad0db[_0x8b24('0x12')][_0x8b24('0x14')]);return _0x51bbad(_0x4ad0db[_0x8b24('0x12')][_0x8b24('0x14')]);}else{logger[_0x8b24('0xc')](_0x8b24('0xd'),_0x588ca8,'request\x20sent');_0x51bbad(_0x4ad0db['result']['message']);}})[_0x8b24('0x15')](function(_0x523863){logger['error'](_0x8b24('0xd'),_0x588ca8,_0x523863);_0x43b851(_0x523863);});});}exports[_0x8b24('0x16')]=function(_0x527af7){var _0x1bafdf=this;return new Promise(function(_0x5e3c52,_0x3b4805){return db['Campaign'][_0x8b24('0x17')]({'raw':_0x527af7['options']?_0x527af7[_0x8b24('0x18')][_0x8b24('0x19')]===undefined?!![]:![]:!![],'where':_0x527af7[_0x8b24('0x18')]?_0x527af7[_0x8b24('0x18')][_0x8b24('0x1a')]||null:null,'attributes':_0x527af7[_0x8b24('0x18')]?_0x527af7[_0x8b24('0x18')]['attributes']||null:null,'limit':_0x527af7[_0x8b24('0x18')]?_0x527af7[_0x8b24('0x18')]['limit']||null:null,'include':_0x527af7[_0x8b24('0x18')]?_0x527af7[_0x8b24('0x18')][_0x8b24('0x1b')]?_[_0x8b24('0x1c')](_0x527af7[_0x8b24('0x18')][_0x8b24('0x1b')],function(_0x347591){return{'model':db[_0x347591[_0x8b24('0x1d')]],'as':_0x347591['as'],'attributes':_0x347591[_0x8b24('0x1e')],'include':_0x347591[_0x8b24('0x1b')]?_[_0x8b24('0x1c')](_0x347591[_0x8b24('0x1b')],function(_0x2cfb27){return{'model':db[_0x2cfb27[_0x8b24('0x1d')]],'as':_0x2cfb27['as'],'attributes':_0x2cfb27[_0x8b24('0x1e')],'include':_0x2cfb27[_0x8b24('0x1b')]?_[_0x8b24('0x1c')](_0x2cfb27[_0x8b24('0x1b')],function(_0x44ee85){return{'model':db[_0x44ee85[_0x8b24('0x1d')]],'as':_0x44ee85['as'],'attributes':_0x44ee85[_0x8b24('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x8b24('0xb')](function(_0x2be377){logger[_0x8b24('0xc')](_0x8b24('0x16'),_0x527af7);logger[_0x8b24('0xf')](_0x8b24('0x16'),_0x527af7,JSON[_0x8b24('0x11')](_0x2be377));_0x5e3c52(_0x2be377);})['catch'](function(_0x36ff89){logger[_0x8b24('0x12')](_0x8b24('0x16'),_0x36ff89[_0x8b24('0x14')],_0x527af7);_0x3b4805(_0x1bafdf[_0x8b24('0x12')](0x1f4,_0x36ff89[_0x8b24('0x14')]));});});};