1db4dd25c7742b27af8499523cd8b9fb6c733387
[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 _0xf430=['limit','include','model','map','lodash','util','moment','randomstring','ioredis','../../config/logger','rpc','../../config/environment','client','http','then','info','Campaign,\x20%s,\x20%s','Campaign,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','GetCampaign','Campaign','options','raw','where','attributes'];(function(_0x3ab9ee,_0x4a74b8){var _0x82ee88=function(_0x6ccc7e){while(--_0x6ccc7e){_0x3ab9ee['push'](_0x3ab9ee['shift']());}};_0x82ee88(++_0x4a74b8);}(_0xf430,0x1e4));var _0x0f43=function(_0x516ffb,_0x5b5b42){_0x516ffb=_0x516ffb-0x0;var _0x319667=_0xf430[_0x516ffb];return _0x319667;};'use strict';var _=require(_0x0f43('0x0'));var util=require(_0x0f43('0x1'));var moment=require(_0x0f43('0x2'));var BPromise=require('bluebird');var rs=require(_0x0f43('0x3'));var fs=require('fs');var Redis=require(_0x0f43('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x0f43('0x5'))(_0x0f43('0x6'));var config=require(_0x0f43('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x0f43('0x8')][_0x0f43('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x490bc1,_0x562cf2,_0x2e8f68){return new BPromise(function(_0x39bc4c,_0x18e735){return client['request'](_0x490bc1,_0x2e8f68)[_0x0f43('0xa')](function(_0x59508b){logger[_0x0f43('0xb')](_0x0f43('0xc'),_0x562cf2,'request\x20sent');logger['debug'](_0x0f43('0xd'),_0x562cf2,_0x0f43('0xe'),JSON[_0x0f43('0xf')](_0x59508b));if(_0x59508b[_0x0f43('0x10')]){if(_0x59508b[_0x0f43('0x10')]['code']===0x1f4){logger[_0x0f43('0x10')](_0x0f43('0xc'),_0x562cf2,_0x59508b[_0x0f43('0x10')][_0x0f43('0x11')]);return _0x18e735(_0x59508b[_0x0f43('0x10')][_0x0f43('0x11')]);}logger[_0x0f43('0x10')](_0x0f43('0xc'),_0x562cf2,_0x59508b[_0x0f43('0x10')][_0x0f43('0x11')]);return _0x39bc4c(_0x59508b[_0x0f43('0x10')]['message']);}else{logger[_0x0f43('0xb')](_0x0f43('0xc'),_0x562cf2,'request\x20sent');_0x39bc4c(_0x59508b[_0x0f43('0x12')][_0x0f43('0x11')]);}})[_0x0f43('0x13')](function(_0x5631e1){logger[_0x0f43('0x10')]('Campaign,\x20%s,\x20%s',_0x562cf2,_0x5631e1);_0x18e735(_0x5631e1);});});}exports[_0x0f43('0x14')]=function(_0x5617c3){var _0x4e294b=this;return new Promise(function(_0x3e25fa,_0x5a7351){return db[_0x0f43('0x15')]['findAll']({'raw':_0x5617c3[_0x0f43('0x16')]?_0x5617c3[_0x0f43('0x16')][_0x0f43('0x17')]===undefined?!![]:![]:!![],'where':_0x5617c3[_0x0f43('0x16')]?_0x5617c3[_0x0f43('0x16')][_0x0f43('0x18')]||null:null,'attributes':_0x5617c3['options']?_0x5617c3[_0x0f43('0x16')][_0x0f43('0x19')]||null:null,'limit':_0x5617c3[_0x0f43('0x16')]?_0x5617c3[_0x0f43('0x16')][_0x0f43('0x1a')]||null:null,'include':_0x5617c3[_0x0f43('0x16')]?_0x5617c3[_0x0f43('0x16')][_0x0f43('0x1b')]?_['map'](_0x5617c3['options'][_0x0f43('0x1b')],function(_0x5c4b61){return{'model':db[_0x5c4b61[_0x0f43('0x1c')]],'as':_0x5c4b61['as'],'attributes':_0x5c4b61[_0x0f43('0x19')],'include':_0x5c4b61[_0x0f43('0x1b')]?_[_0x0f43('0x1d')](_0x5c4b61['include'],function(_0x227f03){return{'model':db[_0x227f03[_0x0f43('0x1c')]],'as':_0x227f03['as'],'attributes':_0x227f03[_0x0f43('0x19')],'include':_0x227f03['include']?_['map'](_0x227f03['include'],function(_0x489fe5){return{'model':db[_0x489fe5[_0x0f43('0x1c')]],'as':_0x489fe5['as'],'attributes':_0x489fe5[_0x0f43('0x19')]};}):[]};}):[]};}):[]:[]})[_0x0f43('0xa')](function(_0x1494e4){logger[_0x0f43('0xb')](_0x0f43('0x14'),_0x5617c3);logger['debug'](_0x0f43('0x14'),_0x5617c3,JSON[_0x0f43('0xf')](_0x1494e4));_0x3e25fa(_0x1494e4);})[_0x0f43('0x13')](function(_0x29e89f){logger[_0x0f43('0x10')]('GetCampaign',_0x29e89f[_0x0f43('0x11')],_0x5617c3);_0x5a7351(_0x4e294b[_0x0f43('0x10')](0x1f4,_0x29e89f[_0x0f43('0x11')]));});});};