Built motion from commit (unavailable).|2.4.3
[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 _0x86c0=['bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','client','http','request','then','info','Campaign,\x20%s,\x20%s','debug','Campaign,\x20%s,\x20%s,\x20%s','request\x20sent','code','error','message','catch','GetCampaign','options','where','attributes','include','map','model','stringify','lodash'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x86c0,0xc3));var _0x086c=function(_0x13cdd0,_0x3a3ca7){_0x13cdd0=_0x13cdd0-0x0;var _0x2fcc49=_0x86c0[_0x13cdd0];return _0x2fcc49;};'use strict';var _=require(_0x086c('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x086c('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x086c('0x2'));var db=require(_0x086c('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x086c('0x4'))(_0x086c('0x5'));var config=require(_0x086c('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x086c('0x7')][_0x086c('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x149bfe,_0x1ad788,_0x2be6e1){return new BPromise(function(_0x5e3d83,_0x2c249f){return client[_0x086c('0x9')](_0x149bfe,_0x2be6e1)[_0x086c('0xa')](function(_0x1648e1){logger[_0x086c('0xb')](_0x086c('0xc'),_0x1ad788,'request\x20sent');logger[_0x086c('0xd')](_0x086c('0xe'),_0x1ad788,_0x086c('0xf'),JSON['stringify'](_0x1648e1));if(_0x1648e1['error']){if(_0x1648e1['error'][_0x086c('0x10')]===0x1f4){logger[_0x086c('0x11')](_0x086c('0xc'),_0x1ad788,_0x1648e1['error']['message']);return _0x2c249f(_0x1648e1[_0x086c('0x11')]['message']);}logger['error']('Campaign,\x20%s,\x20%s',_0x1ad788,_0x1648e1['error']['message']);return _0x5e3d83(_0x1648e1[_0x086c('0x11')][_0x086c('0x12')]);}else{logger[_0x086c('0xb')]('Campaign,\x20%s,\x20%s',_0x1ad788,_0x086c('0xf'));_0x5e3d83(_0x1648e1['result'][_0x086c('0x12')]);}})[_0x086c('0x13')](function(_0x5ce048){logger[_0x086c('0x11')]('Campaign,\x20%s,\x20%s',_0x1ad788,_0x5ce048);_0x2c249f(_0x5ce048);});});}exports[_0x086c('0x14')]=function(_0x4373c){var _0x3b81f3=this;return new Promise(function(_0x24cd1a,_0x344b94){return db['Campaign']['findAll']({'raw':_0x4373c[_0x086c('0x15')]?_0x4373c[_0x086c('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x4373c[_0x086c('0x15')]?_0x4373c[_0x086c('0x15')][_0x086c('0x16')]||null:null,'attributes':_0x4373c['options']?_0x4373c[_0x086c('0x15')][_0x086c('0x17')]||null:null,'limit':_0x4373c[_0x086c('0x15')]?_0x4373c[_0x086c('0x15')]['limit']||null:null,'include':_0x4373c[_0x086c('0x15')]?_0x4373c[_0x086c('0x15')][_0x086c('0x18')]?_[_0x086c('0x19')](_0x4373c['options']['include'],function(_0x5e9cca){return{'model':db[_0x5e9cca[_0x086c('0x1a')]],'as':_0x5e9cca['as'],'attributes':_0x5e9cca['attributes'],'include':_0x5e9cca[_0x086c('0x18')]?_[_0x086c('0x19')](_0x5e9cca[_0x086c('0x18')],function(_0x2d2483){return{'model':db[_0x2d2483[_0x086c('0x1a')]],'as':_0x2d2483['as'],'attributes':_0x2d2483[_0x086c('0x17')],'include':_0x2d2483[_0x086c('0x18')]?_['map'](_0x2d2483[_0x086c('0x18')],function(_0x2a51ed){return{'model':db[_0x2a51ed[_0x086c('0x1a')]],'as':_0x2a51ed['as'],'attributes':_0x2a51ed[_0x086c('0x17')]};}):[]};}):[]};}):[]:[]})[_0x086c('0xa')](function(_0x5bc5eb){logger['info'](_0x086c('0x14'),_0x4373c);logger[_0x086c('0xd')](_0x086c('0x14'),_0x4373c,JSON[_0x086c('0x1b')](_0x5bc5eb));_0x24cd1a(_0x5bc5eb);})[_0x086c('0x13')](function(_0x20f130){logger[_0x086c('0x11')](_0x086c('0x14'),_0x20f130['message'],_0x4373c);_0x344b94(_0x3b81f3['error'](0x1f4,_0x20f130[_0x086c('0x12')]));});});};