Built motion from commit f7863d46.|2.5.41
[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 _0xb43b=['then','Campaign,\x20%s,\x20%s','request\x20sent','debug','Campaign,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','GetCampaign','findAll','options','raw','where','attributes','limit','include','map','model','info','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','request'];(function(_0x286726,_0x20a337){var _0xcd4fe9=function(_0x4d7da6){while(--_0x4d7da6){_0x286726['push'](_0x286726['shift']());}};_0xcd4fe9(++_0x20a337);}(_0xb43b,0xbf));var _0xbb43=function(_0x5e3b51,_0x3f7dc3){_0x5e3b51=_0x5e3b51-0x0;var _0x5c2bb8=_0xb43b[_0x5e3b51];return _0x5c2bb8;};'use strict';var _=require(_0xbb43('0x0'));var util=require('util');var moment=require(_0xbb43('0x1'));var BPromise=require(_0xbb43('0x2'));var rs=require(_0xbb43('0x3'));var fs=require('fs');var Redis=require(_0xbb43('0x4'));var db=require(_0xbb43('0x5'))['db'];var utils=require(_0xbb43('0x6'));var logger=require(_0xbb43('0x7'))(_0xbb43('0x8'));var config=require(_0xbb43('0x9'));var jayson=require(_0xbb43('0xa'));var client=jayson[_0xbb43('0xb')]['http']({'port':0x232a});function respondWithRpcPromise(_0x16fc1c,_0x4a070c,_0x54806a){return new BPromise(function(_0x33f9a8,_0x120d67){return client[_0xbb43('0xc')](_0x16fc1c,_0x54806a)[_0xbb43('0xd')](function(_0x117f4d){logger['info'](_0xbb43('0xe'),_0x4a070c,_0xbb43('0xf'));logger[_0xbb43('0x10')](_0xbb43('0x11'),_0x4a070c,'request\x20sent',JSON[_0xbb43('0x12')](_0x117f4d));if(_0x117f4d[_0xbb43('0x13')]){if(_0x117f4d['error']['code']===0x1f4){logger['error'](_0xbb43('0xe'),_0x4a070c,_0x117f4d['error'][_0xbb43('0x14')]);return _0x120d67(_0x117f4d['error'][_0xbb43('0x14')]);}logger[_0xbb43('0x13')](_0xbb43('0xe'),_0x4a070c,_0x117f4d[_0xbb43('0x13')][_0xbb43('0x14')]);return _0x33f9a8(_0x117f4d['error'][_0xbb43('0x14')]);}else{logger['info'](_0xbb43('0xe'),_0x4a070c,_0xbb43('0xf'));_0x33f9a8(_0x117f4d[_0xbb43('0x15')][_0xbb43('0x14')]);}})[_0xbb43('0x16')](function(_0x126f61){logger[_0xbb43('0x13')](_0xbb43('0xe'),_0x4a070c,_0x126f61);_0x120d67(_0x126f61);});});}exports[_0xbb43('0x17')]=function(_0x4c223b){var _0xe15a1b=this;return new Promise(function(_0x4cb0b2,_0x78df91){return db['Campaign'][_0xbb43('0x18')]({'raw':_0x4c223b[_0xbb43('0x19')]?_0x4c223b[_0xbb43('0x19')][_0xbb43('0x1a')]===undefined?!![]:![]:!![],'where':_0x4c223b['options']?_0x4c223b[_0xbb43('0x19')][_0xbb43('0x1b')]||null:null,'attributes':_0x4c223b[_0xbb43('0x19')]?_0x4c223b[_0xbb43('0x19')][_0xbb43('0x1c')]||null:null,'limit':_0x4c223b[_0xbb43('0x19')]?_0x4c223b[_0xbb43('0x19')][_0xbb43('0x1d')]||null:null,'include':_0x4c223b[_0xbb43('0x19')]?_0x4c223b[_0xbb43('0x19')][_0xbb43('0x1e')]?_[_0xbb43('0x1f')](_0x4c223b[_0xbb43('0x19')][_0xbb43('0x1e')],function(_0x500af4){return{'model':db[_0x500af4[_0xbb43('0x20')]],'as':_0x500af4['as'],'attributes':_0x500af4[_0xbb43('0x1c')],'include':_0x500af4['include']?_[_0xbb43('0x1f')](_0x500af4[_0xbb43('0x1e')],function(_0x25279b){return{'model':db[_0x25279b['model']],'as':_0x25279b['as'],'attributes':_0x25279b['attributes'],'include':_0x25279b[_0xbb43('0x1e')]?_[_0xbb43('0x1f')](_0x25279b['include'],function(_0x48ef60){return{'model':db[_0x48ef60[_0xbb43('0x20')]],'as':_0x48ef60['as'],'attributes':_0x48ef60[_0xbb43('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xbb43('0xd')](function(_0x4bb859){logger[_0xbb43('0x21')](_0xbb43('0x17'),_0x4c223b);logger[_0xbb43('0x10')](_0xbb43('0x17'),_0x4c223b,JSON['stringify'](_0x4bb859));_0x4cb0b2(_0x4bb859);})[_0xbb43('0x16')](function(_0x170e7a){logger[_0xbb43('0x13')](_0xbb43('0x17'),_0x170e7a[_0xbb43('0x14')],_0x4c223b);_0x78df91(_0xe15a1b[_0xbb43('0x13')](0x1f4,_0x170e7a[_0xbb43('0x14')]));});});};