Built motion from commit (unavailable).|2.5.21
[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 _0x1c9a=['limit','include','map','attributes','model','ShowTrigger','find','where','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','info','request\x20sent','debug','Trigger,\x20%s,\x20%s,\x20%s','stringify','error','code','Trigger,\x20%s,\x20%s','message','result','catch','GetTrigger','Trigger','findAll','options','raw'];(function(_0x5b80a9,_0x42a5e0){var _0x268eba=function(_0x39e065){while(--_0x39e065){_0x5b80a9['push'](_0x5b80a9['shift']());}};_0x268eba(++_0x42a5e0);}(_0x1c9a,0x98));var _0xa1c9=function(_0x51d824,_0x121043){_0x51d824=_0x51d824-0x0;var _0x125cfc=_0x1c9a[_0x51d824];return _0x125cfc;};'use strict';var _=require(_0xa1c9('0x0'));var util=require('util');var moment=require(_0xa1c9('0x1'));var BPromise=require('bluebird');var rs=require(_0xa1c9('0x2'));var fs=require('fs');var Redis=require(_0xa1c9('0x3'));var db=require(_0xa1c9('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xa1c9('0x5'))(_0xa1c9('0x6'));var config=require(_0xa1c9('0x7'));var jayson=require(_0xa1c9('0x8'));var client=jayson['client'][_0xa1c9('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x5448f2,_0x222624,_0x463c9c){return new BPromise(function(_0x3f07c2,_0x5059df){return client[_0xa1c9('0xa')](_0x5448f2,_0x463c9c)[_0xa1c9('0xb')](function(_0x24136d){logger[_0xa1c9('0xc')]('Trigger,\x20%s,\x20%s',_0x222624,_0xa1c9('0xd'));logger[_0xa1c9('0xe')](_0xa1c9('0xf'),_0x222624,_0xa1c9('0xd'),JSON[_0xa1c9('0x10')](_0x24136d));if(_0x24136d[_0xa1c9('0x11')]){if(_0x24136d[_0xa1c9('0x11')][_0xa1c9('0x12')]===0x1f4){logger[_0xa1c9('0x11')](_0xa1c9('0x13'),_0x222624,_0x24136d['error'][_0xa1c9('0x14')]);return _0x5059df(_0x24136d[_0xa1c9('0x11')][_0xa1c9('0x14')]);}logger[_0xa1c9('0x11')](_0xa1c9('0x13'),_0x222624,_0x24136d['error'][_0xa1c9('0x14')]);return _0x3f07c2(_0x24136d[_0xa1c9('0x11')][_0xa1c9('0x14')]);}else{logger[_0xa1c9('0xc')](_0xa1c9('0x13'),_0x222624,_0xa1c9('0xd'));_0x3f07c2(_0x24136d[_0xa1c9('0x15')][_0xa1c9('0x14')]);}})[_0xa1c9('0x16')](function(_0x373f5d){logger['error'](_0xa1c9('0x13'),_0x222624,_0x373f5d);_0x5059df(_0x373f5d);});});}exports[_0xa1c9('0x17')]=function(_0x224ae4){var _0x50db9b=this;return new Promise(function(_0x2fb81e,_0x5ab911){return db[_0xa1c9('0x18')][_0xa1c9('0x19')]({'raw':_0x224ae4[_0xa1c9('0x1a')]?_0x224ae4['options'][_0xa1c9('0x1b')]===undefined?!![]:![]:!![],'where':_0x224ae4[_0xa1c9('0x1a')]?_0x224ae4[_0xa1c9('0x1a')]['where']||null:null,'attributes':_0x224ae4[_0xa1c9('0x1a')]?_0x224ae4[_0xa1c9('0x1a')]['attributes']||null:null,'limit':_0x224ae4[_0xa1c9('0x1a')]?_0x224ae4[_0xa1c9('0x1a')][_0xa1c9('0x1c')]||null:null,'include':_0x224ae4['options']?_0x224ae4[_0xa1c9('0x1a')][_0xa1c9('0x1d')]?_[_0xa1c9('0x1e')](_0x224ae4[_0xa1c9('0x1a')][_0xa1c9('0x1d')],function(_0x4a0a0c){return{'model':db[_0x4a0a0c['model']],'as':_0x4a0a0c['as'],'attributes':_0x4a0a0c[_0xa1c9('0x1f')],'include':_0x4a0a0c['include']?_[_0xa1c9('0x1e')](_0x4a0a0c[_0xa1c9('0x1d')],function(_0x1c6f37){return{'model':db[_0x1c6f37[_0xa1c9('0x20')]],'as':_0x1c6f37['as'],'attributes':_0x1c6f37[_0xa1c9('0x1f')],'include':_0x1c6f37['include']?_[_0xa1c9('0x1e')](_0x1c6f37[_0xa1c9('0x1d')],function(_0x20cbe1){return{'model':db[_0x20cbe1['model']],'as':_0x20cbe1['as'],'attributes':_0x20cbe1[_0xa1c9('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xa1c9('0xb')](function(_0x1ca443){logger['info'](_0xa1c9('0x17'),_0x224ae4);logger[_0xa1c9('0xe')]('GetTrigger',_0x224ae4,JSON[_0xa1c9('0x10')](_0x1ca443));_0x2fb81e(_0x1ca443);})['catch'](function(_0xdf6d0c){logger[_0xa1c9('0x11')](_0xa1c9('0x17'),_0xdf6d0c[_0xa1c9('0x14')],_0x224ae4);_0x5ab911(_0x50db9b[_0xa1c9('0x11')](0x1f4,_0xdf6d0c[_0xa1c9('0x14')]));});});};exports[_0xa1c9('0x21')]=function(_0x58b900){var _0x5648b8=this;return new Promise(function(_0x4d23cd,_0x1c7038){return db[_0xa1c9('0x18')][_0xa1c9('0x22')]({'raw':_0x58b900[_0xa1c9('0x1a')]?_0x58b900[_0xa1c9('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x58b900['options']?_0x58b900['options'][_0xa1c9('0x23')]||null:null,'attributes':_0x58b900[_0xa1c9('0x1a')]?_0x58b900[_0xa1c9('0x1a')][_0xa1c9('0x1f')]||null:null,'include':_0x58b900[_0xa1c9('0x1a')]?_0x58b900[_0xa1c9('0x1a')][_0xa1c9('0x1d')]?_['map'](_0x58b900[_0xa1c9('0x1a')]['include'],function(_0x1b8707){return{'model':db[_0x1b8707['model']],'as':_0x1b8707['as'],'attributes':_0x1b8707[_0xa1c9('0x1f')],'include':_0x1b8707[_0xa1c9('0x1d')]?_[_0xa1c9('0x1e')](_0x1b8707['include'],function(_0x39818f){return{'model':db[_0x39818f[_0xa1c9('0x20')]],'as':_0x39818f['as'],'attributes':_0x39818f[_0xa1c9('0x1f')],'include':_0x39818f[_0xa1c9('0x1d')]?_['map'](_0x39818f['include'],function(_0x1f1612){return{'model':db[_0x1f1612[_0xa1c9('0x20')]],'as':_0x1f1612['as'],'attributes':_0x1f1612[_0xa1c9('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xa1c9('0xb')](function(_0x1c0cce){logger[_0xa1c9('0xc')](_0xa1c9('0x21'),_0x58b900);logger[_0xa1c9('0xe')](_0xa1c9('0x21'),_0x58b900,JSON[_0xa1c9('0x10')](_0x1c0cce));_0x4d23cd(_0x1c0cce);})['catch'](function(_0x3e6ec0){logger[_0xa1c9('0x11')](_0xa1c9('0x21'),_0x3e6ec0[_0xa1c9('0x14')],_0x58b900);_0x1c7038(_0x5648b8[_0xa1c9('0x11')](0x1f4,_0x3e6ec0[_0xa1c9('0x14')]));});});};