1d09c502f603c2d37a1ef63c9a432b603351e0f0
[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 _0xc5ba=['limit','map','include','model','then','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','info','Campaign,\x20%s,\x20%s','request\x20sent','debug','Campaign,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetCampaign','Campaign','options','where','attributes'];(function(_0x143368,_0x5d0b64){var _0x44c10a=function(_0x30c90c){while(--_0x30c90c){_0x143368['push'](_0x143368['shift']());}};_0x44c10a(++_0x5d0b64);}(_0xc5ba,0xb9));var _0xac5b=function(_0x16dbcd,_0x274516){_0x16dbcd=_0x16dbcd-0x0;var _0x34706e=_0xc5ba[_0x16dbcd];return _0x34706e;};'use strict';var _=require(_0xac5b('0x0'));var util=require(_0xac5b('0x1'));var moment=require(_0xac5b('0x2'));var BPromise=require(_0xac5b('0x3'));var rs=require(_0xac5b('0x4'));var fs=require('fs');var Redis=require(_0xac5b('0x5'));var db=require(_0xac5b('0x6'))['db'];var utils=require(_0xac5b('0x7'));var logger=require(_0xac5b('0x8'))(_0xac5b('0x9'));var config=require(_0xac5b('0xa'));var jayson=require(_0xac5b('0xb'));var client=jayson[_0xac5b('0xc')][_0xac5b('0xd')]({'port':0x232a});function respondWithRpcPromise(_0x38602a,_0xc09fbc,_0xc193a7){return new BPromise(function(_0x4a7fc7,_0x525e20){return client[_0xac5b('0xe')](_0x38602a,_0xc193a7)['then'](function(_0x3c5bd3){logger[_0xac5b('0xf')](_0xac5b('0x10'),_0xc09fbc,_0xac5b('0x11'));logger[_0xac5b('0x12')](_0xac5b('0x13'),_0xc09fbc,_0xac5b('0x11'),JSON[_0xac5b('0x14')](_0x3c5bd3));if(_0x3c5bd3[_0xac5b('0x15')]){if(_0x3c5bd3['error'][_0xac5b('0x16')]===0x1f4){logger[_0xac5b('0x15')](_0xac5b('0x10'),_0xc09fbc,_0x3c5bd3[_0xac5b('0x15')][_0xac5b('0x17')]);return _0x525e20(_0x3c5bd3[_0xac5b('0x15')][_0xac5b('0x17')]);}logger[_0xac5b('0x15')](_0xac5b('0x10'),_0xc09fbc,_0x3c5bd3[_0xac5b('0x15')][_0xac5b('0x17')]);return _0x4a7fc7(_0x3c5bd3[_0xac5b('0x15')]['message']);}else{logger[_0xac5b('0xf')](_0xac5b('0x10'),_0xc09fbc,_0xac5b('0x11'));_0x4a7fc7(_0x3c5bd3[_0xac5b('0x18')][_0xac5b('0x17')]);}})[_0xac5b('0x19')](function(_0x363de5){logger[_0xac5b('0x15')](_0xac5b('0x10'),_0xc09fbc,_0x363de5);_0x525e20(_0x363de5);});});}exports[_0xac5b('0x1a')]=function(_0x11e6fa){var _0x551ccf=this;return new Promise(function(_0x2db8d1,_0x4c46e5){return db[_0xac5b('0x1b')]['findAll']({'raw':_0x11e6fa[_0xac5b('0x1c')]?_0x11e6fa[_0xac5b('0x1c')]['raw']===undefined?!![]:![]:!![],'where':_0x11e6fa['options']?_0x11e6fa['options'][_0xac5b('0x1d')]||null:null,'attributes':_0x11e6fa['options']?_0x11e6fa[_0xac5b('0x1c')][_0xac5b('0x1e')]||null:null,'limit':_0x11e6fa[_0xac5b('0x1c')]?_0x11e6fa[_0xac5b('0x1c')][_0xac5b('0x1f')]||null:null,'include':_0x11e6fa['options']?_0x11e6fa['options']['include']?_[_0xac5b('0x20')](_0x11e6fa['options'][_0xac5b('0x21')],function(_0x32d186){return{'model':db[_0x32d186['model']],'as':_0x32d186['as'],'attributes':_0x32d186[_0xac5b('0x1e')],'include':_0x32d186[_0xac5b('0x21')]?_[_0xac5b('0x20')](_0x32d186[_0xac5b('0x21')],function(_0x3c3b08){return{'model':db[_0x3c3b08[_0xac5b('0x22')]],'as':_0x3c3b08['as'],'attributes':_0x3c3b08[_0xac5b('0x1e')],'include':_0x3c3b08[_0xac5b('0x21')]?_[_0xac5b('0x20')](_0x3c3b08[_0xac5b('0x21')],function(_0x578d11){return{'model':db[_0x578d11[_0xac5b('0x22')]],'as':_0x578d11['as'],'attributes':_0x578d11[_0xac5b('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xac5b('0x23')](function(_0x4191a7){logger[_0xac5b('0xf')](_0xac5b('0x1a'),_0x11e6fa);logger[_0xac5b('0x12')](_0xac5b('0x1a'),_0x11e6fa,JSON[_0xac5b('0x14')](_0x4191a7));_0x2db8d1(_0x4191a7);})[_0xac5b('0x19')](function(_0x36f1e4){logger['error'](_0xac5b('0x1a'),_0x36f1e4[_0xac5b('0x17')],_0x11e6fa);_0x4c46e5(_0x551ccf[_0xac5b('0x15')](0x1f4,_0x36f1e4['message']));});});};