Built motion from commit e0fa946e.|2.6.5
[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 _0x01fe=['raw','attributes','limit','include','map','model','lodash','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','request','then','info','request\x20sent','debug','error','code','Campaign,\x20%s,\x20%s','message','catch','GetCampaign','findAll','options'];(function(_0x4979b8,_0x5772e5){var _0x58b602=function(_0x10beb6){while(--_0x10beb6){_0x4979b8['push'](_0x4979b8['shift']());}};_0x58b602(++_0x5772e5);}(_0x01fe,0x102));var _0xe01f=function(_0x3dc9d2,_0x276130){_0x3dc9d2=_0x3dc9d2-0x0;var _0x6c0262=_0x01fe[_0x3dc9d2];return _0x6c0262;};'use strict';var _=require(_0xe01f('0x0'));var util=require('util');var moment=require(_0xe01f('0x1'));var BPromise=require(_0xe01f('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xe01f('0x3'))['db'];var utils=require(_0xe01f('0x4'));var logger=require(_0xe01f('0x5'))(_0xe01f('0x6'));var config=require('../../config/environment');var jayson=require(_0xe01f('0x7'));var client=jayson['client'][_0xe01f('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x3b754f,_0x45431b,_0x40376f){return new BPromise(function(_0x377881,_0x4d1775){return client[_0xe01f('0x9')](_0x3b754f,_0x40376f)[_0xe01f('0xa')](function(_0x47dc30){logger[_0xe01f('0xb')]('Campaign,\x20%s,\x20%s',_0x45431b,_0xe01f('0xc'));logger[_0xe01f('0xd')]('Campaign,\x20%s,\x20%s,\x20%s',_0x45431b,_0xe01f('0xc'),JSON['stringify'](_0x47dc30));if(_0x47dc30[_0xe01f('0xe')]){if(_0x47dc30[_0xe01f('0xe')][_0xe01f('0xf')]===0x1f4){logger[_0xe01f('0xe')](_0xe01f('0x10'),_0x45431b,_0x47dc30[_0xe01f('0xe')][_0xe01f('0x11')]);return _0x4d1775(_0x47dc30[_0xe01f('0xe')]['message']);}logger[_0xe01f('0xe')](_0xe01f('0x10'),_0x45431b,_0x47dc30[_0xe01f('0xe')][_0xe01f('0x11')]);return _0x377881(_0x47dc30[_0xe01f('0xe')][_0xe01f('0x11')]);}else{logger[_0xe01f('0xb')]('Campaign,\x20%s,\x20%s',_0x45431b,'request\x20sent');_0x377881(_0x47dc30['result'][_0xe01f('0x11')]);}})[_0xe01f('0x12')](function(_0x88606f){logger[_0xe01f('0xe')](_0xe01f('0x10'),_0x45431b,_0x88606f);_0x4d1775(_0x88606f);});});}exports[_0xe01f('0x13')]=function(_0x144eef){var _0x26cd4d=this;return new Promise(function(_0x9ee4b5,_0x2ddaa3){return db['Campaign'][_0xe01f('0x14')]({'raw':_0x144eef['options']?_0x144eef[_0xe01f('0x15')][_0xe01f('0x16')]===undefined?!![]:![]:!![],'where':_0x144eef[_0xe01f('0x15')]?_0x144eef[_0xe01f('0x15')]['where']||null:null,'attributes':_0x144eef[_0xe01f('0x15')]?_0x144eef[_0xe01f('0x15')][_0xe01f('0x17')]||null:null,'limit':_0x144eef[_0xe01f('0x15')]?_0x144eef[_0xe01f('0x15')][_0xe01f('0x18')]||null:null,'include':_0x144eef['options']?_0x144eef[_0xe01f('0x15')][_0xe01f('0x19')]?_[_0xe01f('0x1a')](_0x144eef[_0xe01f('0x15')][_0xe01f('0x19')],function(_0x38efcc){return{'model':db[_0x38efcc[_0xe01f('0x1b')]],'as':_0x38efcc['as'],'attributes':_0x38efcc[_0xe01f('0x17')],'include':_0x38efcc[_0xe01f('0x19')]?_['map'](_0x38efcc['include'],function(_0x3138d3){return{'model':db[_0x3138d3[_0xe01f('0x1b')]],'as':_0x3138d3['as'],'attributes':_0x3138d3[_0xe01f('0x17')],'include':_0x3138d3[_0xe01f('0x19')]?_['map'](_0x3138d3[_0xe01f('0x19')],function(_0x42b213){return{'model':db[_0x42b213['model']],'as':_0x42b213['as'],'attributes':_0x42b213[_0xe01f('0x17')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1b77c8){logger[_0xe01f('0xb')](_0xe01f('0x13'),_0x144eef);logger['debug'](_0xe01f('0x13'),_0x144eef,JSON['stringify'](_0x1b77c8));_0x9ee4b5(_0x1b77c8);})[_0xe01f('0x12')](function(_0x232ad1){logger[_0xe01f('0xe')](_0xe01f('0x13'),_0x232ad1[_0xe01f('0x11')],_0x144eef);_0x2ddaa3(_0x26cd4d[_0xe01f('0xe')](0x1f4,_0x232ad1[_0xe01f('0x11')]));});});};