Built motion from commit d1eab355.|2.6.28
[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 _0xdafb=['raw','debug','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','info','Trigger,\x20%s,\x20%s','stringify','error','message','request\x20sent','result','catch','GetTrigger','Trigger','findAll','options','where','limit','include','map','model','attributes','then','ShowTrigger'];(function(_0x684477,_0x5136f7){var _0x4bee66=function(_0x228b61){while(--_0x228b61){_0x684477['push'](_0x684477['shift']());}};_0x4bee66(++_0x5136f7);}(_0xdafb,0xce));var _0xbdaf=function(_0x132e4f,_0x3e9e91){_0x132e4f=_0x132e4f-0x0;var _0x43cea1=_0xdafb[_0x132e4f];return _0x43cea1;};'use strict';var _=require(_0xbdaf('0x0'));var util=require(_0xbdaf('0x1'));var moment=require(_0xbdaf('0x2'));var BPromise=require(_0xbdaf('0x3'));var rs=require(_0xbdaf('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xbdaf('0x5'))['db'];var utils=require(_0xbdaf('0x6'));var logger=require(_0xbdaf('0x7'))(_0xbdaf('0x8'));var config=require('../../config/environment');var jayson=require(_0xbdaf('0x9'));var client=jayson[_0xbdaf('0xa')][_0xbdaf('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x43b21a,_0xfc5d1a,_0x3b3b7f){return new BPromise(function(_0x6f099c,_0x147810){return client['request'](_0x43b21a,_0x3b3b7f)['then'](function(_0x4e18bf){logger[_0xbdaf('0xc')](_0xbdaf('0xd'),_0xfc5d1a,'request\x20sent');logger['debug']('Trigger,\x20%s,\x20%s,\x20%s',_0xfc5d1a,'request\x20sent',JSON[_0xbdaf('0xe')](_0x4e18bf));if(_0x4e18bf['error']){if(_0x4e18bf[_0xbdaf('0xf')]['code']===0x1f4){logger[_0xbdaf('0xf')](_0xbdaf('0xd'),_0xfc5d1a,_0x4e18bf[_0xbdaf('0xf')][_0xbdaf('0x10')]);return _0x147810(_0x4e18bf['error'][_0xbdaf('0x10')]);}logger['error'](_0xbdaf('0xd'),_0xfc5d1a,_0x4e18bf[_0xbdaf('0xf')]['message']);return _0x6f099c(_0x4e18bf['error']['message']);}else{logger[_0xbdaf('0xc')](_0xbdaf('0xd'),_0xfc5d1a,_0xbdaf('0x11'));_0x6f099c(_0x4e18bf[_0xbdaf('0x12')][_0xbdaf('0x10')]);}})[_0xbdaf('0x13')](function(_0xc4162){logger[_0xbdaf('0xf')]('Trigger,\x20%s,\x20%s',_0xfc5d1a,_0xc4162);_0x147810(_0xc4162);});});}exports[_0xbdaf('0x14')]=function(_0x389d98){var _0x17fee5=this;return new Promise(function(_0x3a4f11,_0x45d65b){return db[_0xbdaf('0x15')][_0xbdaf('0x16')]({'raw':_0x389d98[_0xbdaf('0x17')]?_0x389d98[_0xbdaf('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x389d98[_0xbdaf('0x17')]?_0x389d98[_0xbdaf('0x17')][_0xbdaf('0x18')]||null:null,'attributes':_0x389d98['options']?_0x389d98['options']['attributes']||null:null,'limit':_0x389d98[_0xbdaf('0x17')]?_0x389d98[_0xbdaf('0x17')][_0xbdaf('0x19')]||null:null,'include':_0x389d98[_0xbdaf('0x17')]?_0x389d98[_0xbdaf('0x17')][_0xbdaf('0x1a')]?_[_0xbdaf('0x1b')](_0x389d98[_0xbdaf('0x17')]['include'],function(_0x432897){return{'model':db[_0x432897[_0xbdaf('0x1c')]],'as':_0x432897['as'],'attributes':_0x432897[_0xbdaf('0x1d')],'include':_0x432897[_0xbdaf('0x1a')]?_[_0xbdaf('0x1b')](_0x432897[_0xbdaf('0x1a')],function(_0x3cfc66){return{'model':db[_0x3cfc66[_0xbdaf('0x1c')]],'as':_0x3cfc66['as'],'attributes':_0x3cfc66['attributes'],'include':_0x3cfc66[_0xbdaf('0x1a')]?_[_0xbdaf('0x1b')](_0x3cfc66['include'],function(_0x429eb3){return{'model':db[_0x429eb3[_0xbdaf('0x1c')]],'as':_0x429eb3['as'],'attributes':_0x429eb3['attributes']};}):[]};}):[]};}):[]:[]})[_0xbdaf('0x1e')](function(_0x28f7cd){logger[_0xbdaf('0xc')]('GetTrigger',_0x389d98);logger['debug'](_0xbdaf('0x14'),_0x389d98,JSON[_0xbdaf('0xe')](_0x28f7cd));_0x3a4f11(_0x28f7cd);})[_0xbdaf('0x13')](function(_0x316622){logger[_0xbdaf('0xf')](_0xbdaf('0x14'),_0x316622[_0xbdaf('0x10')],_0x389d98);_0x45d65b(_0x17fee5['error'](0x1f4,_0x316622[_0xbdaf('0x10')]));});});};exports[_0xbdaf('0x1f')]=function(_0x561c9e){var _0x27d9ad=this;return new Promise(function(_0x49f625,_0x497b6b){return db[_0xbdaf('0x15')]['find']({'raw':_0x561c9e[_0xbdaf('0x17')]?_0x561c9e[_0xbdaf('0x17')][_0xbdaf('0x20')]===undefined?!![]:![]:!![],'where':_0x561c9e[_0xbdaf('0x17')]?_0x561c9e[_0xbdaf('0x17')][_0xbdaf('0x18')]||null:null,'attributes':_0x561c9e['options']?_0x561c9e[_0xbdaf('0x17')]['attributes']||null:null,'include':_0x561c9e[_0xbdaf('0x17')]?_0x561c9e['options'][_0xbdaf('0x1a')]?_[_0xbdaf('0x1b')](_0x561c9e[_0xbdaf('0x17')][_0xbdaf('0x1a')],function(_0x57a51b){return{'model':db[_0x57a51b[_0xbdaf('0x1c')]],'as':_0x57a51b['as'],'attributes':_0x57a51b[_0xbdaf('0x1d')],'include':_0x57a51b['include']?_[_0xbdaf('0x1b')](_0x57a51b[_0xbdaf('0x1a')],function(_0x438cdd){return{'model':db[_0x438cdd[_0xbdaf('0x1c')]],'as':_0x438cdd['as'],'attributes':_0x438cdd[_0xbdaf('0x1d')],'include':_0x438cdd[_0xbdaf('0x1a')]?_[_0xbdaf('0x1b')](_0x438cdd[_0xbdaf('0x1a')],function(_0x421fd3){return{'model':db[_0x421fd3[_0xbdaf('0x1c')]],'as':_0x421fd3['as'],'attributes':_0x421fd3[_0xbdaf('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x158ca8){logger['info'](_0xbdaf('0x1f'),_0x561c9e);logger[_0xbdaf('0x21')](_0xbdaf('0x1f'),_0x561c9e,JSON[_0xbdaf('0xe')](_0x158ca8));_0x49f625(_0x158ca8);})[_0xbdaf('0x13')](function(_0x2fa2aa){logger[_0xbdaf('0xf')](_0xbdaf('0x1f'),_0x2fa2aa['message'],_0x561c9e);_0x497b6b(_0x27d9ad['error'](0x1f4,_0x2fa2aa[_0xbdaf('0x10')]));});});};