Built motion from commit 71df090e.|2.6.31
[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 _0x2060=['Campaign,\x20%s,\x20%s,\x20%s','stringify','code','error','message','result','catch','GetCampaign','Campaign','findAll','options','raw','where','attributes','map','include','model','lodash','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','client','http','request','then','info','Campaign,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x17d9e3,_0x1f969c){var _0x14192d=function(_0x159745){while(--_0x159745){_0x17d9e3['push'](_0x17d9e3['shift']());}};_0x14192d(++_0x1f969c);}(_0x2060,0x1be));var _0x0206=function(_0x57f295,_0x4ca3c4){_0x57f295=_0x57f295-0x0;var _0x51fd23=_0x2060[_0x57f295];return _0x51fd23;};'use strict';var _=require(_0x0206('0x0'));var util=require('util');var moment=require(_0x0206('0x1'));var BPromise=require(_0x0206('0x2'));var rs=require(_0x0206('0x3'));var fs=require('fs');var Redis=require(_0x0206('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x0206('0x5'));var logger=require(_0x0206('0x6'))('rpc');var config=require(_0x0206('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x0206('0x8')][_0x0206('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x529d59,_0x2eda0e,_0x5c8dbb){return new BPromise(function(_0x4ffb51,_0x46dd94){return client[_0x0206('0xa')](_0x529d59,_0x5c8dbb)[_0x0206('0xb')](function(_0x194718){logger[_0x0206('0xc')](_0x0206('0xd'),_0x2eda0e,_0x0206('0xe'));logger[_0x0206('0xf')](_0x0206('0x10'),_0x2eda0e,_0x0206('0xe'),JSON[_0x0206('0x11')](_0x194718));if(_0x194718['error']){if(_0x194718['error'][_0x0206('0x12')]===0x1f4){logger[_0x0206('0x13')]('Campaign,\x20%s,\x20%s',_0x2eda0e,_0x194718[_0x0206('0x13')][_0x0206('0x14')]);return _0x46dd94(_0x194718[_0x0206('0x13')]['message']);}logger[_0x0206('0x13')](_0x0206('0xd'),_0x2eda0e,_0x194718[_0x0206('0x13')][_0x0206('0x14')]);return _0x4ffb51(_0x194718['error'][_0x0206('0x14')]);}else{logger['info'](_0x0206('0xd'),_0x2eda0e,_0x0206('0xe'));_0x4ffb51(_0x194718[_0x0206('0x15')][_0x0206('0x14')]);}})[_0x0206('0x16')](function(_0x26c261){logger['error']('Campaign,\x20%s,\x20%s',_0x2eda0e,_0x26c261);_0x46dd94(_0x26c261);});});}exports[_0x0206('0x17')]=function(_0x5641df){var _0x58291b=this;return new Promise(function(_0x2db2da,_0x3ecd80){return db[_0x0206('0x18')][_0x0206('0x19')]({'raw':_0x5641df['options']?_0x5641df[_0x0206('0x1a')][_0x0206('0x1b')]===undefined?!![]:![]:!![],'where':_0x5641df[_0x0206('0x1a')]?_0x5641df[_0x0206('0x1a')][_0x0206('0x1c')]||null:null,'attributes':_0x5641df[_0x0206('0x1a')]?_0x5641df[_0x0206('0x1a')][_0x0206('0x1d')]||null:null,'limit':_0x5641df['options']?_0x5641df[_0x0206('0x1a')]['limit']||null:null,'include':_0x5641df['options']?_0x5641df[_0x0206('0x1a')]['include']?_[_0x0206('0x1e')](_0x5641df[_0x0206('0x1a')][_0x0206('0x1f')],function(_0x4c5452){return{'model':db[_0x4c5452[_0x0206('0x20')]],'as':_0x4c5452['as'],'attributes':_0x4c5452[_0x0206('0x1d')],'include':_0x4c5452[_0x0206('0x1f')]?_['map'](_0x4c5452['include'],function(_0x3b9890){return{'model':db[_0x3b9890[_0x0206('0x20')]],'as':_0x3b9890['as'],'attributes':_0x3b9890['attributes'],'include':_0x3b9890[_0x0206('0x1f')]?_[_0x0206('0x1e')](_0x3b9890[_0x0206('0x1f')],function(_0x38ebfe){return{'model':db[_0x38ebfe[_0x0206('0x20')]],'as':_0x38ebfe['as'],'attributes':_0x38ebfe['attributes']};}):[]};}):[]};}):[]:[]})[_0x0206('0xb')](function(_0x18513c){logger[_0x0206('0xc')]('GetCampaign',_0x5641df);logger[_0x0206('0xf')](_0x0206('0x17'),_0x5641df,JSON[_0x0206('0x11')](_0x18513c));_0x2db2da(_0x18513c);})['catch'](function(_0xe6320c){logger[_0x0206('0x13')]('GetCampaign',_0xe6320c[_0x0206('0x14')],_0x5641df);_0x3ecd80(_0x58291b[_0x0206('0x13')](0x1f4,_0xe6320c[_0x0206('0x14')]));});});};