Built motion from commit (unavailable).|2.2.0
[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 _0xf8e0=['map','model','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','client','http','then','info','Campaign,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','catch','GetCampaign','Campaign','findAll','options','where','attributes','include'];(function(_0x3144b3,_0x45f961){var _0x2517a9=function(_0x15af07){while(--_0x15af07){_0x3144b3['push'](_0x3144b3['shift']());}};_0x2517a9(++_0x45f961);}(_0xf8e0,0x1ef));var _0x0f8e=function(_0x5e645a,_0x14e641){_0x5e645a=_0x5e645a-0x0;var _0x7e069b=_0xf8e0[_0x5e645a];return _0x7e069b;};'use strict';var _=require('lodash');var util=require(_0x0f8e('0x0'));var moment=require(_0x0f8e('0x1'));var BPromise=require(_0x0f8e('0x2'));var rs=require(_0x0f8e('0x3'));var fs=require('fs');var Redis=require(_0x0f8e('0x4'));var db=require(_0x0f8e('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x0f8e('0x6'))(_0x0f8e('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x0f8e('0x8')][_0x0f8e('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x5289d2,_0x37d262,_0x4e6de2){return new BPromise(function(_0x55adb7,_0x2e3a3c){return client['request'](_0x5289d2,_0x4e6de2)[_0x0f8e('0xa')](function(_0x4f6cd1){logger[_0x0f8e('0xb')](_0x0f8e('0xc'),_0x37d262,_0x0f8e('0xd'));logger[_0x0f8e('0xe')]('Campaign,\x20%s,\x20%s,\x20%s',_0x37d262,_0x0f8e('0xd'),JSON[_0x0f8e('0xf')](_0x4f6cd1));if(_0x4f6cd1['error']){if(_0x4f6cd1[_0x0f8e('0x10')][_0x0f8e('0x11')]===0x1f4){logger[_0x0f8e('0x10')](_0x0f8e('0xc'),_0x37d262,_0x4f6cd1[_0x0f8e('0x10')][_0x0f8e('0x12')]);return _0x2e3a3c(_0x4f6cd1[_0x0f8e('0x10')][_0x0f8e('0x12')]);}logger[_0x0f8e('0x10')](_0x0f8e('0xc'),_0x37d262,_0x4f6cd1[_0x0f8e('0x10')][_0x0f8e('0x12')]);return _0x55adb7(_0x4f6cd1[_0x0f8e('0x10')][_0x0f8e('0x12')]);}else{logger[_0x0f8e('0xb')](_0x0f8e('0xc'),_0x37d262,'request\x20sent');_0x55adb7(_0x4f6cd1['result']['message']);}})[_0x0f8e('0x13')](function(_0x12c195){logger[_0x0f8e('0x10')](_0x0f8e('0xc'),_0x37d262,_0x12c195);_0x2e3a3c(_0x12c195);});});}exports[_0x0f8e('0x14')]=function(_0x1c41ab){var _0x27db98=this;return new Promise(function(_0x1a12a1,_0xc0e658){return db[_0x0f8e('0x15')][_0x0f8e('0x16')]({'raw':_0x1c41ab[_0x0f8e('0x17')]?_0x1c41ab[_0x0f8e('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x1c41ab[_0x0f8e('0x17')]?_0x1c41ab[_0x0f8e('0x17')][_0x0f8e('0x18')]||null:null,'attributes':_0x1c41ab[_0x0f8e('0x17')]?_0x1c41ab[_0x0f8e('0x17')][_0x0f8e('0x19')]||null:null,'limit':_0x1c41ab['options']?_0x1c41ab[_0x0f8e('0x17')]['limit']||null:null,'include':_0x1c41ab[_0x0f8e('0x17')]?_0x1c41ab[_0x0f8e('0x17')][_0x0f8e('0x1a')]?_['map'](_0x1c41ab[_0x0f8e('0x17')][_0x0f8e('0x1a')],function(_0x16604c){return{'model':db[_0x16604c['model']],'as':_0x16604c['as'],'attributes':_0x16604c[_0x0f8e('0x19')],'include':_0x16604c[_0x0f8e('0x1a')]?_[_0x0f8e('0x1b')](_0x16604c[_0x0f8e('0x1a')],function(_0x198924){return{'model':db[_0x198924[_0x0f8e('0x1c')]],'as':_0x198924['as'],'attributes':_0x198924[_0x0f8e('0x19')],'include':_0x198924[_0x0f8e('0x1a')]?_['map'](_0x198924[_0x0f8e('0x1a')],function(_0x2a366d){return{'model':db[_0x2a366d[_0x0f8e('0x1c')]],'as':_0x2a366d['as'],'attributes':_0x2a366d[_0x0f8e('0x19')]};}):[]};}):[]};}):[]:[]})[_0x0f8e('0xa')](function(_0x11ed9e){logger[_0x0f8e('0xb')](_0x0f8e('0x14'),_0x1c41ab);logger[_0x0f8e('0xe')](_0x0f8e('0x14'),_0x1c41ab,JSON[_0x0f8e('0xf')](_0x11ed9e));_0x1a12a1(_0x11ed9e);})[_0x0f8e('0x13')](function(_0x568bb6){logger[_0x0f8e('0x10')](_0x0f8e('0x14'),_0x568bb6[_0x0f8e('0x12')],_0x1c41ab);_0xc0e658(_0x27db98[_0x0f8e('0x10')](0x1f4,_0x568bb6[_0x0f8e('0x12')]));});});};