Built motion from commit b5a10faa.|2.6.13
[motion2.git] / server / api / trigger / trigger.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 _0xec4a=['bluebird','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','request','Trigger,\x20%s,\x20%s','request\x20sent','Trigger,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','GetTrigger','findAll','options','where','limit','include','map','model','attributes','then','debug','Trigger','find','raw','lodash','moment'];(function(_0x2ce6d5,_0x333e0c){var _0x32d272=function(_0x399f0b){while(--_0x399f0b){_0x2ce6d5['push'](_0x2ce6d5['shift']());}};_0x32d272(++_0x333e0c);}(_0xec4a,0x1ab));var _0xaec4=function(_0xed4dd1,_0x4279d0){_0xed4dd1=_0xed4dd1-0x0;var _0x32dbbd=_0xec4a[_0xed4dd1];return _0x32dbbd;};'use strict';var _=require(_0xaec4('0x0'));var util=require('util');var moment=require(_0xaec4('0x1'));var BPromise=require(_0xaec4('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xaec4('0x3'))['db'];var utils=require(_0xaec4('0x4'));var logger=require('../../config/logger')(_0xaec4('0x5'));var config=require(_0xaec4('0x6'));var jayson=require(_0xaec4('0x7'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x4a8e31,_0x121819,_0x186af7){return new BPromise(function(_0x4b0465,_0x3c54dd){return client[_0xaec4('0x8')](_0x4a8e31,_0x186af7)['then'](function(_0x280fd2){logger['info'](_0xaec4('0x9'),_0x121819,_0xaec4('0xa'));logger['debug'](_0xaec4('0xb'),_0x121819,_0xaec4('0xa'),JSON[_0xaec4('0xc')](_0x280fd2));if(_0x280fd2[_0xaec4('0xd')]){if(_0x280fd2[_0xaec4('0xd')][_0xaec4('0xe')]===0x1f4){logger[_0xaec4('0xd')](_0xaec4('0x9'),_0x121819,_0x280fd2['error'][_0xaec4('0xf')]);return _0x3c54dd(_0x280fd2[_0xaec4('0xd')][_0xaec4('0xf')]);}logger[_0xaec4('0xd')](_0xaec4('0x9'),_0x121819,_0x280fd2[_0xaec4('0xd')]['message']);return _0x4b0465(_0x280fd2['error'][_0xaec4('0xf')]);}else{logger[_0xaec4('0x10')](_0xaec4('0x9'),_0x121819,_0xaec4('0xa'));_0x4b0465(_0x280fd2[_0xaec4('0x11')]['message']);}})[_0xaec4('0x12')](function(_0x27b24c){logger[_0xaec4('0xd')](_0xaec4('0x9'),_0x121819,_0x27b24c);_0x3c54dd(_0x27b24c);});});}exports[_0xaec4('0x13')]=function(_0x12e65f){var _0x41272d=this;return new Promise(function(_0x57400b,_0x2c73b4){return db['Trigger'][_0xaec4('0x14')]({'raw':_0x12e65f[_0xaec4('0x15')]?_0x12e65f[_0xaec4('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x12e65f[_0xaec4('0x15')]?_0x12e65f['options'][_0xaec4('0x16')]||null:null,'attributes':_0x12e65f[_0xaec4('0x15')]?_0x12e65f[_0xaec4('0x15')]['attributes']||null:null,'limit':_0x12e65f['options']?_0x12e65f[_0xaec4('0x15')][_0xaec4('0x17')]||null:null,'include':_0x12e65f[_0xaec4('0x15')]?_0x12e65f['options'][_0xaec4('0x18')]?_[_0xaec4('0x19')](_0x12e65f[_0xaec4('0x15')][_0xaec4('0x18')],function(_0x3a3a82){return{'model':db[_0x3a3a82[_0xaec4('0x1a')]],'as':_0x3a3a82['as'],'attributes':_0x3a3a82[_0xaec4('0x1b')],'include':_0x3a3a82[_0xaec4('0x18')]?_[_0xaec4('0x19')](_0x3a3a82[_0xaec4('0x18')],function(_0x19e240){return{'model':db[_0x19e240[_0xaec4('0x1a')]],'as':_0x19e240['as'],'attributes':_0x19e240['attributes'],'include':_0x19e240[_0xaec4('0x18')]?_['map'](_0x19e240['include'],function(_0x2226c7){return{'model':db[_0x2226c7[_0xaec4('0x1a')]],'as':_0x2226c7['as'],'attributes':_0x2226c7[_0xaec4('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xaec4('0x1c')](function(_0x323c9e){logger['info']('GetTrigger',_0x12e65f);logger[_0xaec4('0x1d')](_0xaec4('0x13'),_0x12e65f,JSON[_0xaec4('0xc')](_0x323c9e));_0x57400b(_0x323c9e);})[_0xaec4('0x12')](function(_0x4d468f){logger['error'](_0xaec4('0x13'),_0x4d468f[_0xaec4('0xf')],_0x12e65f);_0x2c73b4(_0x41272d['error'](0x1f4,_0x4d468f[_0xaec4('0xf')]));});});};exports['ShowTrigger']=function(_0xb56699){var _0x53c2fa=this;return new Promise(function(_0x380031,_0x58ec8a){return db[_0xaec4('0x1e')][_0xaec4('0x1f')]({'raw':_0xb56699['options']?_0xb56699[_0xaec4('0x15')][_0xaec4('0x20')]===undefined?!![]:![]:!![],'where':_0xb56699[_0xaec4('0x15')]?_0xb56699['options'][_0xaec4('0x16')]||null:null,'attributes':_0xb56699[_0xaec4('0x15')]?_0xb56699[_0xaec4('0x15')]['attributes']||null:null,'include':_0xb56699[_0xaec4('0x15')]?_0xb56699[_0xaec4('0x15')]['include']?_['map'](_0xb56699[_0xaec4('0x15')][_0xaec4('0x18')],function(_0x4c56f0){return{'model':db[_0x4c56f0['model']],'as':_0x4c56f0['as'],'attributes':_0x4c56f0[_0xaec4('0x1b')],'include':_0x4c56f0['include']?_[_0xaec4('0x19')](_0x4c56f0[_0xaec4('0x18')],function(_0x4d0f7a){return{'model':db[_0x4d0f7a[_0xaec4('0x1a')]],'as':_0x4d0f7a['as'],'attributes':_0x4d0f7a[_0xaec4('0x1b')],'include':_0x4d0f7a['include']?_[_0xaec4('0x19')](_0x4d0f7a[_0xaec4('0x18')],function(_0x8f3cf6){return{'model':db[_0x8f3cf6[_0xaec4('0x1a')]],'as':_0x8f3cf6['as'],'attributes':_0x8f3cf6[_0xaec4('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xaec4('0x1c')](function(_0xf9475d){logger[_0xaec4('0x10')]('ShowTrigger',_0xb56699);logger['debug']('ShowTrigger',_0xb56699,JSON[_0xaec4('0xc')](_0xf9475d));_0x380031(_0xf9475d);})['catch'](function(_0x2987ac){logger[_0xaec4('0xd')]('ShowTrigger',_0x2987ac[_0xaec4('0xf')],_0xb56699);_0x58ec8a(_0x53c2fa[_0xaec4('0xd')](0x1f4,_0x2987ac[_0xaec4('0xf')]));});});};