Built motion from commit (unavailable).|2.4.0
[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 _0x3013=['stringify','error','message','result','catch','Trigger','findAll','options','raw','limit','include','model','attributes','map','GetTrigger','ShowTrigger','find','where','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','then','info','Trigger,\x20%s,\x20%s','request\x20sent','debug','Trigger,\x20%s,\x20%s,\x20%s'];(function(_0x3914f5,_0x2751b8){var _0x245cb5=function(_0x3c1167){while(--_0x3c1167){_0x3914f5['push'](_0x3914f5['shift']());}};_0x245cb5(++_0x2751b8);}(_0x3013,0x1f3));var _0x3301=function(_0x5bdbc1,_0xafcb4a){_0x5bdbc1=_0x5bdbc1-0x0;var _0x17a0d5=_0x3013[_0x5bdbc1];return _0x17a0d5;};'use strict';var _=require(_0x3301('0x0'));var util=require(_0x3301('0x1'));var moment=require(_0x3301('0x2'));var BPromise=require(_0x3301('0x3'));var rs=require(_0x3301('0x4'));var fs=require('fs');var Redis=require(_0x3301('0x5'));var db=require(_0x3301('0x6'))['db'];var utils=require(_0x3301('0x7'));var logger=require(_0x3301('0x8'))(_0x3301('0x9'));var config=require(_0x3301('0xa'));var jayson=require(_0x3301('0xb'));var client=jayson['client'][_0x3301('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x4a2575,_0x481dd1,_0x58adfe){return new BPromise(function(_0x2e6281,_0x234abe){return client['request'](_0x4a2575,_0x58adfe)[_0x3301('0xd')](function(_0xd20cf7){logger[_0x3301('0xe')](_0x3301('0xf'),_0x481dd1,_0x3301('0x10'));logger[_0x3301('0x11')](_0x3301('0x12'),_0x481dd1,_0x3301('0x10'),JSON[_0x3301('0x13')](_0xd20cf7));if(_0xd20cf7[_0x3301('0x14')]){if(_0xd20cf7[_0x3301('0x14')]['code']===0x1f4){logger['error']('Trigger,\x20%s,\x20%s',_0x481dd1,_0xd20cf7[_0x3301('0x14')][_0x3301('0x15')]);return _0x234abe(_0xd20cf7[_0x3301('0x14')][_0x3301('0x15')]);}logger[_0x3301('0x14')](_0x3301('0xf'),_0x481dd1,_0xd20cf7['error'][_0x3301('0x15')]);return _0x2e6281(_0xd20cf7[_0x3301('0x14')]['message']);}else{logger[_0x3301('0xe')](_0x3301('0xf'),_0x481dd1,_0x3301('0x10'));_0x2e6281(_0xd20cf7[_0x3301('0x16')][_0x3301('0x15')]);}})[_0x3301('0x17')](function(_0x10970c){logger[_0x3301('0x14')](_0x3301('0xf'),_0x481dd1,_0x10970c);_0x234abe(_0x10970c);});});}exports['GetTrigger']=function(_0x4937cc){var _0x28aa04=this;return new Promise(function(_0x193c35,_0x549a1a){return db[_0x3301('0x18')][_0x3301('0x19')]({'raw':_0x4937cc['options']?_0x4937cc[_0x3301('0x1a')][_0x3301('0x1b')]===undefined?!![]:![]:!![],'where':_0x4937cc[_0x3301('0x1a')]?_0x4937cc[_0x3301('0x1a')]['where']||null:null,'attributes':_0x4937cc[_0x3301('0x1a')]?_0x4937cc[_0x3301('0x1a')]['attributes']||null:null,'limit':_0x4937cc[_0x3301('0x1a')]?_0x4937cc[_0x3301('0x1a')][_0x3301('0x1c')]||null:null,'include':_0x4937cc[_0x3301('0x1a')]?_0x4937cc[_0x3301('0x1a')][_0x3301('0x1d')]?_['map'](_0x4937cc[_0x3301('0x1a')][_0x3301('0x1d')],function(_0x236424){return{'model':db[_0x236424[_0x3301('0x1e')]],'as':_0x236424['as'],'attributes':_0x236424[_0x3301('0x1f')],'include':_0x236424[_0x3301('0x1d')]?_[_0x3301('0x20')](_0x236424[_0x3301('0x1d')],function(_0x95e70c){return{'model':db[_0x95e70c[_0x3301('0x1e')]],'as':_0x95e70c['as'],'attributes':_0x95e70c[_0x3301('0x1f')],'include':_0x95e70c[_0x3301('0x1d')]?_['map'](_0x95e70c[_0x3301('0x1d')],function(_0x2bf978){return{'model':db[_0x2bf978[_0x3301('0x1e')]],'as':_0x2bf978['as'],'attributes':_0x2bf978[_0x3301('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x3301('0xd')](function(_0x14c14f){logger[_0x3301('0xe')](_0x3301('0x21'),_0x4937cc);logger[_0x3301('0x11')]('GetTrigger',_0x4937cc,JSON[_0x3301('0x13')](_0x14c14f));_0x193c35(_0x14c14f);})['catch'](function(_0x3a01f9){logger[_0x3301('0x14')](_0x3301('0x21'),_0x3a01f9[_0x3301('0x15')],_0x4937cc);_0x549a1a(_0x28aa04[_0x3301('0x14')](0x1f4,_0x3a01f9[_0x3301('0x15')]));});});};exports[_0x3301('0x22')]=function(_0x47502c){var _0x1294c9=this;return new Promise(function(_0x21f2a3,_0x4c9789){return db[_0x3301('0x18')][_0x3301('0x23')]({'raw':_0x47502c[_0x3301('0x1a')]?_0x47502c[_0x3301('0x1a')][_0x3301('0x1b')]===undefined?!![]:![]:!![],'where':_0x47502c[_0x3301('0x1a')]?_0x47502c['options'][_0x3301('0x24')]||null:null,'attributes':_0x47502c[_0x3301('0x1a')]?_0x47502c[_0x3301('0x1a')][_0x3301('0x1f')]||null:null,'include':_0x47502c['options']?_0x47502c[_0x3301('0x1a')]['include']?_[_0x3301('0x20')](_0x47502c[_0x3301('0x1a')][_0x3301('0x1d')],function(_0x39677b){return{'model':db[_0x39677b[_0x3301('0x1e')]],'as':_0x39677b['as'],'attributes':_0x39677b[_0x3301('0x1f')],'include':_0x39677b[_0x3301('0x1d')]?_[_0x3301('0x20')](_0x39677b[_0x3301('0x1d')],function(_0x4f891d){return{'model':db[_0x4f891d['model']],'as':_0x4f891d['as'],'attributes':_0x4f891d[_0x3301('0x1f')],'include':_0x4f891d[_0x3301('0x1d')]?_['map'](_0x4f891d[_0x3301('0x1d')],function(_0x186134){return{'model':db[_0x186134[_0x3301('0x1e')]],'as':_0x186134['as'],'attributes':_0x186134['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x2a203a){logger[_0x3301('0xe')](_0x3301('0x22'),_0x47502c);logger[_0x3301('0x11')]('ShowTrigger',_0x47502c,JSON['stringify'](_0x2a203a));_0x21f2a3(_0x2a203a);})['catch'](function(_0x2a1d04){logger[_0x3301('0x14')](_0x3301('0x22'),_0x2a1d04[_0x3301('0x15')],_0x47502c);_0x4c9789(_0x1294c9[_0x3301('0x14')](0x1f4,_0x2a1d04[_0x3301('0x15')]));});});};