Built motion from commit (unavailable).|2.3.5
[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 _0xbfd0=['error','code','Campaign,\x20%s,\x20%s','message','info','result','catch','GetCampaign','findAll','options','raw','where','attributes','limit','include','map','model','then','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','http','request\x20sent','debug','Campaign,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x35fff3,_0x14c28f){var _0x42b127=function(_0x4e556b){while(--_0x4e556b){_0x35fff3['push'](_0x35fff3['shift']());}};_0x42b127(++_0x14c28f);}(_0xbfd0,0x78));var _0x0bfd=function(_0x1f36bb,_0x8af718){_0x1f36bb=_0x1f36bb-0x0;var _0xaf97fa=_0xbfd0[_0x1f36bb];return _0xaf97fa;};'use strict';var _=require(_0x0bfd('0x0'));var util=require(_0x0bfd('0x1'));var moment=require(_0x0bfd('0x2'));var BPromise=require(_0x0bfd('0x3'));var rs=require(_0x0bfd('0x4'));var fs=require('fs');var Redis=require(_0x0bfd('0x5'));var db=require(_0x0bfd('0x6'))['db'];var utils=require(_0x0bfd('0x7'));var logger=require('../../config/logger')(_0x0bfd('0x8'));var config=require(_0x0bfd('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x0bfd('0xa')][_0x0bfd('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x33be01,_0x14c1fc,_0x108ffc){return new BPromise(function(_0x42600c,_0x372d8f){return client['request'](_0x33be01,_0x108ffc)['then'](function(_0xee3fe){logger['info']('Campaign,\x20%s,\x20%s',_0x14c1fc,_0x0bfd('0xc'));logger[_0x0bfd('0xd')](_0x0bfd('0xe'),_0x14c1fc,_0x0bfd('0xc'),JSON[_0x0bfd('0xf')](_0xee3fe));if(_0xee3fe[_0x0bfd('0x10')]){if(_0xee3fe[_0x0bfd('0x10')][_0x0bfd('0x11')]===0x1f4){logger[_0x0bfd('0x10')](_0x0bfd('0x12'),_0x14c1fc,_0xee3fe[_0x0bfd('0x10')][_0x0bfd('0x13')]);return _0x372d8f(_0xee3fe[_0x0bfd('0x10')][_0x0bfd('0x13')]);}logger['error'](_0x0bfd('0x12'),_0x14c1fc,_0xee3fe[_0x0bfd('0x10')]['message']);return _0x42600c(_0xee3fe['error'][_0x0bfd('0x13')]);}else{logger[_0x0bfd('0x14')]('Campaign,\x20%s,\x20%s',_0x14c1fc,_0x0bfd('0xc'));_0x42600c(_0xee3fe[_0x0bfd('0x15')][_0x0bfd('0x13')]);}})[_0x0bfd('0x16')](function(_0x297dd4){logger[_0x0bfd('0x10')](_0x0bfd('0x12'),_0x14c1fc,_0x297dd4);_0x372d8f(_0x297dd4);});});}exports[_0x0bfd('0x17')]=function(_0x19f576){var _0x4181e1=this;return new Promise(function(_0x871be0,_0xcf1de8){return db['Campaign'][_0x0bfd('0x18')]({'raw':_0x19f576[_0x0bfd('0x19')]?_0x19f576[_0x0bfd('0x19')][_0x0bfd('0x1a')]===undefined?!![]:![]:!![],'where':_0x19f576['options']?_0x19f576[_0x0bfd('0x19')][_0x0bfd('0x1b')]||null:null,'attributes':_0x19f576[_0x0bfd('0x19')]?_0x19f576['options'][_0x0bfd('0x1c')]||null:null,'limit':_0x19f576[_0x0bfd('0x19')]?_0x19f576[_0x0bfd('0x19')][_0x0bfd('0x1d')]||null:null,'include':_0x19f576[_0x0bfd('0x19')]?_0x19f576[_0x0bfd('0x19')][_0x0bfd('0x1e')]?_[_0x0bfd('0x1f')](_0x19f576[_0x0bfd('0x19')][_0x0bfd('0x1e')],function(_0x43d9af){return{'model':db[_0x43d9af['model']],'as':_0x43d9af['as'],'attributes':_0x43d9af[_0x0bfd('0x1c')],'include':_0x43d9af['include']?_[_0x0bfd('0x1f')](_0x43d9af[_0x0bfd('0x1e')],function(_0x391663){return{'model':db[_0x391663[_0x0bfd('0x20')]],'as':_0x391663['as'],'attributes':_0x391663[_0x0bfd('0x1c')],'include':_0x391663[_0x0bfd('0x1e')]?_[_0x0bfd('0x1f')](_0x391663[_0x0bfd('0x1e')],function(_0x33fd38){return{'model':db[_0x33fd38[_0x0bfd('0x20')]],'as':_0x33fd38['as'],'attributes':_0x33fd38[_0x0bfd('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x0bfd('0x21')](function(_0x45c78a){logger[_0x0bfd('0x14')]('GetCampaign',_0x19f576);logger[_0x0bfd('0xd')](_0x0bfd('0x17'),_0x19f576,JSON[_0x0bfd('0xf')](_0x45c78a));_0x871be0(_0x45c78a);})[_0x0bfd('0x16')](function(_0x45ed0a){logger['error'](_0x0bfd('0x17'),_0x45ed0a['message'],_0x19f576);_0xcf1de8(_0x4181e1[_0x0bfd('0x10')](0x1f4,_0x45ed0a[_0x0bfd('0x13')]));});});};