Built motion from commit fe909640.|2.6.8
[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 _0xbf82=['stringify','error','code','message','result','GetCampaign','Campaign','findAll','options','raw','where','limit','include','map','model','attributes','catch','lodash','moment','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http','request','then','info','Campaign,\x20%s,\x20%s','request\x20sent','debug','Campaign,\x20%s,\x20%s,\x20%s'];(function(_0x124ee4,_0x5b1868){var _0x4f5a17=function(_0x5af76a){while(--_0x5af76a){_0x124ee4['push'](_0x124ee4['shift']());}};_0x4f5a17(++_0x5b1868);}(_0xbf82,0x1cb));var _0x2bf8=function(_0x131a37,_0x1ee0fa){_0x131a37=_0x131a37-0x0;var _0xea16d8=_0xbf82[_0x131a37];return _0xea16d8;};'use strict';var _=require(_0x2bf8('0x0'));var util=require('util');var moment=require(_0x2bf8('0x1'));var BPromise=require('bluebird');var rs=require(_0x2bf8('0x2'));var fs=require('fs');var Redis=require(_0x2bf8('0x3'));var db=require(_0x2bf8('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x2bf8('0x5'));var config=require(_0x2bf8('0x6'));var jayson=require(_0x2bf8('0x7'));var client=jayson[_0x2bf8('0x8')][_0x2bf8('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x5a3818,_0x586bd5,_0x1c57e9){return new BPromise(function(_0x5c1944,_0x130e6d){return client[_0x2bf8('0xa')](_0x5a3818,_0x1c57e9)[_0x2bf8('0xb')](function(_0x596d31){logger[_0x2bf8('0xc')](_0x2bf8('0xd'),_0x586bd5,_0x2bf8('0xe'));logger[_0x2bf8('0xf')](_0x2bf8('0x10'),_0x586bd5,_0x2bf8('0xe'),JSON[_0x2bf8('0x11')](_0x596d31));if(_0x596d31[_0x2bf8('0x12')]){if(_0x596d31[_0x2bf8('0x12')][_0x2bf8('0x13')]===0x1f4){logger[_0x2bf8('0x12')]('Campaign,\x20%s,\x20%s',_0x586bd5,_0x596d31[_0x2bf8('0x12')]['message']);return _0x130e6d(_0x596d31[_0x2bf8('0x12')]['message']);}logger['error'](_0x2bf8('0xd'),_0x586bd5,_0x596d31[_0x2bf8('0x12')][_0x2bf8('0x14')]);return _0x5c1944(_0x596d31[_0x2bf8('0x12')][_0x2bf8('0x14')]);}else{logger['info']('Campaign,\x20%s,\x20%s',_0x586bd5,_0x2bf8('0xe'));_0x5c1944(_0x596d31[_0x2bf8('0x15')][_0x2bf8('0x14')]);}})['catch'](function(_0x15c040){logger[_0x2bf8('0x12')](_0x2bf8('0xd'),_0x586bd5,_0x15c040);_0x130e6d(_0x15c040);});});}exports[_0x2bf8('0x16')]=function(_0x58a39f){var _0x5da512=this;return new Promise(function(_0x1882ae,_0x36600a){return db[_0x2bf8('0x17')][_0x2bf8('0x18')]({'raw':_0x58a39f['options']?_0x58a39f[_0x2bf8('0x19')][_0x2bf8('0x1a')]===undefined?!![]:![]:!![],'where':_0x58a39f[_0x2bf8('0x19')]?_0x58a39f[_0x2bf8('0x19')][_0x2bf8('0x1b')]||null:null,'attributes':_0x58a39f[_0x2bf8('0x19')]?_0x58a39f['options']['attributes']||null:null,'limit':_0x58a39f[_0x2bf8('0x19')]?_0x58a39f[_0x2bf8('0x19')][_0x2bf8('0x1c')]||null:null,'include':_0x58a39f[_0x2bf8('0x19')]?_0x58a39f[_0x2bf8('0x19')][_0x2bf8('0x1d')]?_[_0x2bf8('0x1e')](_0x58a39f['options'][_0x2bf8('0x1d')],function(_0x3991db){return{'model':db[_0x3991db[_0x2bf8('0x1f')]],'as':_0x3991db['as'],'attributes':_0x3991db[_0x2bf8('0x20')],'include':_0x3991db['include']?_[_0x2bf8('0x1e')](_0x3991db[_0x2bf8('0x1d')],function(_0x73d18e){return{'model':db[_0x73d18e[_0x2bf8('0x1f')]],'as':_0x73d18e['as'],'attributes':_0x73d18e['attributes'],'include':_0x73d18e['include']?_[_0x2bf8('0x1e')](_0x73d18e[_0x2bf8('0x1d')],function(_0x4b2152){return{'model':db[_0x4b2152[_0x2bf8('0x1f')]],'as':_0x4b2152['as'],'attributes':_0x4b2152[_0x2bf8('0x20')]};}):[]};}):[]};}):[]:[]})[_0x2bf8('0xb')](function(_0x2ea1d6){logger[_0x2bf8('0xc')](_0x2bf8('0x16'),_0x58a39f);logger[_0x2bf8('0xf')](_0x2bf8('0x16'),_0x58a39f,JSON[_0x2bf8('0x11')](_0x2ea1d6));_0x1882ae(_0x2ea1d6);})[_0x2bf8('0x21')](function(_0x5b5b50){logger['error'](_0x2bf8('0x16'),_0x5b5b50[_0x2bf8('0x14')],_0x58a39f);_0x36600a(_0x5da512['error'](0x1f4,_0x5b5b50[_0x2bf8('0x14')]));});});};