Built motion from commit a61a4a20.|2.5.46
[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 _0x81a4=['raw','attributes','limit','include','map','model','lodash','util','moment','bluebird','ioredis','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','then','Campaign,\x20%s,\x20%s','request\x20sent','debug','Campaign,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','catch','GetCampaign','Campaign','options'];(function(_0x465aa9,_0x1bf1c8){var _0x4104e4=function(_0x388bb8){while(--_0x388bb8){_0x465aa9['push'](_0x465aa9['shift']());}};_0x4104e4(++_0x1bf1c8);}(_0x81a4,0x1a6));var _0x481a=function(_0x3c4f1f,_0x20d3ec){_0x3c4f1f=_0x3c4f1f-0x0;var _0x19cb69=_0x81a4[_0x3c4f1f];return _0x19cb69;};'use strict';var _=require(_0x481a('0x0'));var util=require(_0x481a('0x1'));var moment=require(_0x481a('0x2'));var BPromise=require(_0x481a('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x481a('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x481a('0x5'));var logger=require(_0x481a('0x6'))(_0x481a('0x7'));var config=require('../../config/environment');var jayson=require(_0x481a('0x8'));var client=jayson[_0x481a('0x9')][_0x481a('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x14b819,_0x4a5a92,_0x13ed10){return new BPromise(function(_0x13b771,_0x9b7dd5){return client[_0x481a('0xb')](_0x14b819,_0x13ed10)[_0x481a('0xc')](function(_0x59580e){logger['info'](_0x481a('0xd'),_0x4a5a92,_0x481a('0xe'));logger[_0x481a('0xf')](_0x481a('0x10'),_0x4a5a92,_0x481a('0xe'),JSON[_0x481a('0x11')](_0x59580e));if(_0x59580e[_0x481a('0x12')]){if(_0x59580e[_0x481a('0x12')][_0x481a('0x13')]===0x1f4){logger[_0x481a('0x12')]('Campaign,\x20%s,\x20%s',_0x4a5a92,_0x59580e['error'][_0x481a('0x14')]);return _0x9b7dd5(_0x59580e[_0x481a('0x12')][_0x481a('0x14')]);}logger[_0x481a('0x12')](_0x481a('0xd'),_0x4a5a92,_0x59580e[_0x481a('0x12')]['message']);return _0x13b771(_0x59580e[_0x481a('0x12')]['message']);}else{logger[_0x481a('0x15')](_0x481a('0xd'),_0x4a5a92,_0x481a('0xe'));_0x13b771(_0x59580e['result']['message']);}})[_0x481a('0x16')](function(_0xa5746f){logger[_0x481a('0x12')](_0x481a('0xd'),_0x4a5a92,_0xa5746f);_0x9b7dd5(_0xa5746f);});});}exports[_0x481a('0x17')]=function(_0x3186e3){var _0xe4e8fe=this;return new Promise(function(_0x2e6d4e,_0x38c15e){return db[_0x481a('0x18')]['findAll']({'raw':_0x3186e3[_0x481a('0x19')]?_0x3186e3[_0x481a('0x19')][_0x481a('0x1a')]===undefined?!![]:![]:!![],'where':_0x3186e3[_0x481a('0x19')]?_0x3186e3[_0x481a('0x19')]['where']||null:null,'attributes':_0x3186e3[_0x481a('0x19')]?_0x3186e3[_0x481a('0x19')][_0x481a('0x1b')]||null:null,'limit':_0x3186e3[_0x481a('0x19')]?_0x3186e3['options'][_0x481a('0x1c')]||null:null,'include':_0x3186e3[_0x481a('0x19')]?_0x3186e3[_0x481a('0x19')][_0x481a('0x1d')]?_[_0x481a('0x1e')](_0x3186e3[_0x481a('0x19')][_0x481a('0x1d')],function(_0x6a554b){return{'model':db[_0x6a554b['model']],'as':_0x6a554b['as'],'attributes':_0x6a554b[_0x481a('0x1b')],'include':_0x6a554b[_0x481a('0x1d')]?_['map'](_0x6a554b[_0x481a('0x1d')],function(_0x4916fa){return{'model':db[_0x4916fa[_0x481a('0x1f')]],'as':_0x4916fa['as'],'attributes':_0x4916fa[_0x481a('0x1b')],'include':_0x4916fa[_0x481a('0x1d')]?_[_0x481a('0x1e')](_0x4916fa['include'],function(_0x42acf4){return{'model':db[_0x42acf4[_0x481a('0x1f')]],'as':_0x42acf4['as'],'attributes':_0x42acf4[_0x481a('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x481a('0xc')](function(_0x20aeb5){logger[_0x481a('0x15')]('GetCampaign',_0x3186e3);logger[_0x481a('0xf')](_0x481a('0x17'),_0x3186e3,JSON[_0x481a('0x11')](_0x20aeb5));_0x2e6d4e(_0x20aeb5);})[_0x481a('0x16')](function(_0x4e9d26){logger[_0x481a('0x12')](_0x481a('0x17'),_0x4e9d26[_0x481a('0x14')],_0x3186e3);_0x38c15e(_0xe4e8fe[_0x481a('0x12')](0x1f4,_0x4e9d26['message']));});});};