Built motion from commit da24aabd.|2.6.20
[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 _0xaf5a=['include','map','model','GetCampaign','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','then','info','request\x20sent','debug','Campaign,\x20%s,\x20%s,\x20%s','stringify','error','code','Campaign,\x20%s,\x20%s','message','result','catch','Campaign','options','raw','where','attributes','limit'];(function(_0x4aa9aa,_0xc47ab4){var _0x1ef7b7=function(_0x3ddfca){while(--_0x3ddfca){_0x4aa9aa['push'](_0x4aa9aa['shift']());}};_0x1ef7b7(++_0xc47ab4);}(_0xaf5a,0x144));var _0xaaf5=function(_0x493503,_0x351993){_0x493503=_0x493503-0x0;var _0x1986d0=_0xaf5a[_0x493503];return _0x1986d0;};'use strict';var _=require('lodash');var util=require(_0xaaf5('0x0'));var moment=require('moment');var BPromise=require(_0xaaf5('0x1'));var rs=require(_0xaaf5('0x2'));var fs=require('fs');var Redis=require(_0xaaf5('0x3'));var db=require(_0xaaf5('0x4'))['db'];var utils=require(_0xaaf5('0x5'));var logger=require(_0xaaf5('0x6'))(_0xaaf5('0x7'));var config=require(_0xaaf5('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xaaf5('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x39dfd9,_0x34e141,_0x1160d2){return new BPromise(function(_0x2eee5e,_0x3582a5){return client['request'](_0x39dfd9,_0x1160d2)[_0xaaf5('0xa')](function(_0x32c5e6){logger[_0xaaf5('0xb')]('Campaign,\x20%s,\x20%s',_0x34e141,_0xaaf5('0xc'));logger[_0xaaf5('0xd')](_0xaaf5('0xe'),_0x34e141,_0xaaf5('0xc'),JSON[_0xaaf5('0xf')](_0x32c5e6));if(_0x32c5e6[_0xaaf5('0x10')]){if(_0x32c5e6[_0xaaf5('0x10')][_0xaaf5('0x11')]===0x1f4){logger[_0xaaf5('0x10')](_0xaaf5('0x12'),_0x34e141,_0x32c5e6['error'][_0xaaf5('0x13')]);return _0x3582a5(_0x32c5e6[_0xaaf5('0x10')][_0xaaf5('0x13')]);}logger[_0xaaf5('0x10')](_0xaaf5('0x12'),_0x34e141,_0x32c5e6[_0xaaf5('0x10')][_0xaaf5('0x13')]);return _0x2eee5e(_0x32c5e6[_0xaaf5('0x10')]['message']);}else{logger['info']('Campaign,\x20%s,\x20%s',_0x34e141,_0xaaf5('0xc'));_0x2eee5e(_0x32c5e6[_0xaaf5('0x14')]['message']);}})[_0xaaf5('0x15')](function(_0x431f5e){logger[_0xaaf5('0x10')]('Campaign,\x20%s,\x20%s',_0x34e141,_0x431f5e);_0x3582a5(_0x431f5e);});});}exports['GetCampaign']=function(_0x236371){var _0x29d42a=this;return new Promise(function(_0x2f7bdc,_0x37b34a){return db[_0xaaf5('0x16')]['findAll']({'raw':_0x236371[_0xaaf5('0x17')]?_0x236371[_0xaaf5('0x17')][_0xaaf5('0x18')]===undefined?!![]:![]:!![],'where':_0x236371[_0xaaf5('0x17')]?_0x236371[_0xaaf5('0x17')][_0xaaf5('0x19')]||null:null,'attributes':_0x236371[_0xaaf5('0x17')]?_0x236371[_0xaaf5('0x17')][_0xaaf5('0x1a')]||null:null,'limit':_0x236371['options']?_0x236371[_0xaaf5('0x17')][_0xaaf5('0x1b')]||null:null,'include':_0x236371[_0xaaf5('0x17')]?_0x236371[_0xaaf5('0x17')][_0xaaf5('0x1c')]?_[_0xaaf5('0x1d')](_0x236371[_0xaaf5('0x17')][_0xaaf5('0x1c')],function(_0x577761){return{'model':db[_0x577761[_0xaaf5('0x1e')]],'as':_0x577761['as'],'attributes':_0x577761[_0xaaf5('0x1a')],'include':_0x577761[_0xaaf5('0x1c')]?_[_0xaaf5('0x1d')](_0x577761[_0xaaf5('0x1c')],function(_0x46dacd){return{'model':db[_0x46dacd[_0xaaf5('0x1e')]],'as':_0x46dacd['as'],'attributes':_0x46dacd[_0xaaf5('0x1a')],'include':_0x46dacd[_0xaaf5('0x1c')]?_[_0xaaf5('0x1d')](_0x46dacd['include'],function(_0x8b417e){return{'model':db[_0x8b417e[_0xaaf5('0x1e')]],'as':_0x8b417e['as'],'attributes':_0x8b417e[_0xaaf5('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xaaf5('0xa')](function(_0x6915e6){logger[_0xaaf5('0xb')](_0xaaf5('0x1f'),_0x236371);logger['debug'](_0xaaf5('0x1f'),_0x236371,JSON[_0xaaf5('0xf')](_0x6915e6));_0x2f7bdc(_0x6915e6);})[_0xaaf5('0x15')](function(_0x49c7f2){logger['error'](_0xaaf5('0x1f'),_0x49c7f2['message'],_0x236371);_0x37b34a(_0x29d42a[_0xaaf5('0x10')](0x1f4,_0x49c7f2['message']));});});};