Built motion from commit 753c950e.|2.5.42
[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 _0x85db=['Trigger,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','catch','Trigger','findAll','options','raw','where','limit','include','map','model','attributes','then','GetTrigger','debug','find','ShowTrigger','util','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','Trigger,\x20%s,\x20%s','request\x20sent'];(function(_0x3858f4,_0x522d7e){var _0x1300ec=function(_0x5049e6){while(--_0x5049e6){_0x3858f4['push'](_0x3858f4['shift']());}};_0x1300ec(++_0x522d7e);}(_0x85db,0x1c6));var _0xb85d=function(_0x2125f0,_0x2f23b9){_0x2125f0=_0x2125f0-0x0;var _0x12d6eb=_0x85db[_0x2125f0];return _0x12d6eb;};'use strict';var _=require('lodash');var util=require(_0xb85d('0x0'));var moment=require(_0xb85d('0x1'));var BPromise=require(_0xb85d('0x2'));var rs=require(_0xb85d('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xb85d('0x4'));var logger=require(_0xb85d('0x5'))(_0xb85d('0x6'));var config=require(_0xb85d('0x7'));var jayson=require(_0xb85d('0x8'));var client=jayson[_0xb85d('0x9')][_0xb85d('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x9787f7,_0x3b975a,_0x2016c1){return new BPromise(function(_0x18ff80,_0x3e08ff){return client[_0xb85d('0xb')](_0x9787f7,_0x2016c1)['then'](function(_0x2b576d){logger['info'](_0xb85d('0xc'),_0x3b975a,_0xb85d('0xd'));logger['debug'](_0xb85d('0xe'),_0x3b975a,'request\x20sent',JSON[_0xb85d('0xf')](_0x2b576d));if(_0x2b576d[_0xb85d('0x10')]){if(_0x2b576d[_0xb85d('0x10')]['code']===0x1f4){logger[_0xb85d('0x10')](_0xb85d('0xc'),_0x3b975a,_0x2b576d[_0xb85d('0x10')][_0xb85d('0x11')]);return _0x3e08ff(_0x2b576d[_0xb85d('0x10')][_0xb85d('0x11')]);}logger[_0xb85d('0x10')](_0xb85d('0xc'),_0x3b975a,_0x2b576d[_0xb85d('0x10')][_0xb85d('0x11')]);return _0x18ff80(_0x2b576d['error'][_0xb85d('0x11')]);}else{logger[_0xb85d('0x12')](_0xb85d('0xc'),_0x3b975a,_0xb85d('0xd'));_0x18ff80(_0x2b576d[_0xb85d('0x13')]['message']);}})[_0xb85d('0x14')](function(_0x333c9a){logger[_0xb85d('0x10')]('Trigger,\x20%s,\x20%s',_0x3b975a,_0x333c9a);_0x3e08ff(_0x333c9a);});});}exports['GetTrigger']=function(_0x125543){var _0x245ff2=this;return new Promise(function(_0x580549,_0x1babc1){return db[_0xb85d('0x15')][_0xb85d('0x16')]({'raw':_0x125543['options']?_0x125543[_0xb85d('0x17')][_0xb85d('0x18')]===undefined?!![]:![]:!![],'where':_0x125543[_0xb85d('0x17')]?_0x125543['options'][_0xb85d('0x19')]||null:null,'attributes':_0x125543[_0xb85d('0x17')]?_0x125543['options']['attributes']||null:null,'limit':_0x125543['options']?_0x125543[_0xb85d('0x17')][_0xb85d('0x1a')]||null:null,'include':_0x125543[_0xb85d('0x17')]?_0x125543[_0xb85d('0x17')][_0xb85d('0x1b')]?_[_0xb85d('0x1c')](_0x125543['options'][_0xb85d('0x1b')],function(_0x1f6640){return{'model':db[_0x1f6640[_0xb85d('0x1d')]],'as':_0x1f6640['as'],'attributes':_0x1f6640[_0xb85d('0x1e')],'include':_0x1f6640[_0xb85d('0x1b')]?_[_0xb85d('0x1c')](_0x1f6640[_0xb85d('0x1b')],function(_0x34aa02){return{'model':db[_0x34aa02[_0xb85d('0x1d')]],'as':_0x34aa02['as'],'attributes':_0x34aa02[_0xb85d('0x1e')],'include':_0x34aa02[_0xb85d('0x1b')]?_[_0xb85d('0x1c')](_0x34aa02[_0xb85d('0x1b')],function(_0x501928){return{'model':db[_0x501928[_0xb85d('0x1d')]],'as':_0x501928['as'],'attributes':_0x501928[_0xb85d('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xb85d('0x1f')](function(_0x20a88f){logger['info'](_0xb85d('0x20'),_0x125543);logger[_0xb85d('0x21')]('GetTrigger',_0x125543,JSON['stringify'](_0x20a88f));_0x580549(_0x20a88f);})[_0xb85d('0x14')](function(_0x2f98da){logger['error'](_0xb85d('0x20'),_0x2f98da[_0xb85d('0x11')],_0x125543);_0x1babc1(_0x245ff2[_0xb85d('0x10')](0x1f4,_0x2f98da[_0xb85d('0x11')]));});});};exports['ShowTrigger']=function(_0x2f8874){var _0xd29fb0=this;return new Promise(function(_0x265a0d,_0x14adbe){return db['Trigger'][_0xb85d('0x22')]({'raw':_0x2f8874[_0xb85d('0x17')]?_0x2f8874['options']['raw']===undefined?!![]:![]:!![],'where':_0x2f8874[_0xb85d('0x17')]?_0x2f8874['options']['where']||null:null,'attributes':_0x2f8874[_0xb85d('0x17')]?_0x2f8874[_0xb85d('0x17')][_0xb85d('0x1e')]||null:null,'include':_0x2f8874[_0xb85d('0x17')]?_0x2f8874[_0xb85d('0x17')][_0xb85d('0x1b')]?_['map'](_0x2f8874[_0xb85d('0x17')][_0xb85d('0x1b')],function(_0x3faf4e){return{'model':db[_0x3faf4e[_0xb85d('0x1d')]],'as':_0x3faf4e['as'],'attributes':_0x3faf4e['attributes'],'include':_0x3faf4e['include']?_[_0xb85d('0x1c')](_0x3faf4e['include'],function(_0x69b9f1){return{'model':db[_0x69b9f1['model']],'as':_0x69b9f1['as'],'attributes':_0x69b9f1['attributes'],'include':_0x69b9f1[_0xb85d('0x1b')]?_[_0xb85d('0x1c')](_0x69b9f1[_0xb85d('0x1b')],function(_0x79dfde){return{'model':db[_0x79dfde[_0xb85d('0x1d')]],'as':_0x79dfde['as'],'attributes':_0x79dfde[_0xb85d('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xb85d('0x1f')](function(_0x254441){logger[_0xb85d('0x12')](_0xb85d('0x23'),_0x2f8874);logger['debug'](_0xb85d('0x23'),_0x2f8874,JSON['stringify'](_0x254441));_0x265a0d(_0x254441);})[_0xb85d('0x14')](function(_0x21e3e7){logger['error'](_0xb85d('0x23'),_0x21e3e7[_0xb85d('0x11')],_0x2f8874);_0x14adbe(_0xd29fb0[_0xb85d('0x10')](0x1f4,_0x21e3e7[_0xb85d('0x11')]));});});};