dafcb69c68cc381b4245d549bd20e82ff04e497a
[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 _0xbb25=['Trigger','findAll','options','where','attributes','limit','include','map','model','stringify','ShowTrigger','find','raw','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','Trigger,\x20%s,\x20%s','request\x20sent','debug','Trigger,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','GetTrigger'];(function(_0xb0f7c3,_0x4eae95){var _0x28ea68=function(_0x4395a7){while(--_0x4395a7){_0xb0f7c3['push'](_0xb0f7c3['shift']());}};_0x28ea68(++_0x4eae95);}(_0xbb25,0xf1));var _0x5bb2=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xbb25[_0x3dd15e];return _0x231fd0;};'use strict';var _=require('lodash');var util=require(_0x5bb2('0x0'));var moment=require('moment');var BPromise=require(_0x5bb2('0x1'));var rs=require(_0x5bb2('0x2'));var fs=require('fs');var Redis=require(_0x5bb2('0x3'));var db=require(_0x5bb2('0x4'))['db'];var utils=require(_0x5bb2('0x5'));var logger=require(_0x5bb2('0x6'))(_0x5bb2('0x7'));var config=require(_0x5bb2('0x8'));var jayson=require(_0x5bb2('0x9'));var client=jayson[_0x5bb2('0xa')][_0x5bb2('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x2ff7f2,_0x38cdcd,_0x4e6be5){return new BPromise(function(_0x54bb69,_0xd6ff5a){return client[_0x5bb2('0xc')](_0x2ff7f2,_0x4e6be5)[_0x5bb2('0xd')](function(_0x1ea05f){logger[_0x5bb2('0xe')](_0x5bb2('0xf'),_0x38cdcd,_0x5bb2('0x10'));logger[_0x5bb2('0x11')](_0x5bb2('0x12'),_0x38cdcd,_0x5bb2('0x10'),JSON['stringify'](_0x1ea05f));if(_0x1ea05f[_0x5bb2('0x13')]){if(_0x1ea05f[_0x5bb2('0x13')][_0x5bb2('0x14')]===0x1f4){logger[_0x5bb2('0x13')](_0x5bb2('0xf'),_0x38cdcd,_0x1ea05f['error'][_0x5bb2('0x15')]);return _0xd6ff5a(_0x1ea05f[_0x5bb2('0x13')][_0x5bb2('0x15')]);}logger[_0x5bb2('0x13')](_0x5bb2('0xf'),_0x38cdcd,_0x1ea05f[_0x5bb2('0x13')][_0x5bb2('0x15')]);return _0x54bb69(_0x1ea05f[_0x5bb2('0x13')][_0x5bb2('0x15')]);}else{logger[_0x5bb2('0xe')]('Trigger,\x20%s,\x20%s',_0x38cdcd,_0x5bb2('0x10'));_0x54bb69(_0x1ea05f[_0x5bb2('0x16')][_0x5bb2('0x15')]);}})[_0x5bb2('0x17')](function(_0x2b6676){logger[_0x5bb2('0x13')](_0x5bb2('0xf'),_0x38cdcd,_0x2b6676);_0xd6ff5a(_0x2b6676);});});}exports[_0x5bb2('0x18')]=function(_0x266db8){var _0x3314ea=this;return new Promise(function(_0x4f960a,_0x53ce49){return db[_0x5bb2('0x19')][_0x5bb2('0x1a')]({'raw':_0x266db8[_0x5bb2('0x1b')]?_0x266db8[_0x5bb2('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x266db8[_0x5bb2('0x1b')]?_0x266db8['options'][_0x5bb2('0x1c')]||null:null,'attributes':_0x266db8['options']?_0x266db8[_0x5bb2('0x1b')][_0x5bb2('0x1d')]||null:null,'limit':_0x266db8[_0x5bb2('0x1b')]?_0x266db8[_0x5bb2('0x1b')][_0x5bb2('0x1e')]||null:null,'include':_0x266db8['options']?_0x266db8[_0x5bb2('0x1b')][_0x5bb2('0x1f')]?_[_0x5bb2('0x20')](_0x266db8[_0x5bb2('0x1b')][_0x5bb2('0x1f')],function(_0x4c47b8){return{'model':db[_0x4c47b8[_0x5bb2('0x21')]],'as':_0x4c47b8['as'],'attributes':_0x4c47b8['attributes'],'include':_0x4c47b8[_0x5bb2('0x1f')]?_[_0x5bb2('0x20')](_0x4c47b8['include'],function(_0x5c9497){return{'model':db[_0x5c9497[_0x5bb2('0x21')]],'as':_0x5c9497['as'],'attributes':_0x5c9497[_0x5bb2('0x1d')],'include':_0x5c9497[_0x5bb2('0x1f')]?_[_0x5bb2('0x20')](_0x5c9497[_0x5bb2('0x1f')],function(_0x44c848){return{'model':db[_0x44c848[_0x5bb2('0x21')]],'as':_0x44c848['as'],'attributes':_0x44c848[_0x5bb2('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x5bb2('0xd')](function(_0x424c60){logger['info'](_0x5bb2('0x18'),_0x266db8);logger['debug'](_0x5bb2('0x18'),_0x266db8,JSON[_0x5bb2('0x22')](_0x424c60));_0x4f960a(_0x424c60);})[_0x5bb2('0x17')](function(_0x5e2f87){logger['error'](_0x5bb2('0x18'),_0x5e2f87[_0x5bb2('0x15')],_0x266db8);_0x53ce49(_0x3314ea[_0x5bb2('0x13')](0x1f4,_0x5e2f87['message']));});});};exports[_0x5bb2('0x23')]=function(_0x3388b2){var _0x14499d=this;return new Promise(function(_0x5bb07b,_0xfd42ad){return db[_0x5bb2('0x19')][_0x5bb2('0x24')]({'raw':_0x3388b2[_0x5bb2('0x1b')]?_0x3388b2['options'][_0x5bb2('0x25')]===undefined?!![]:![]:!![],'where':_0x3388b2[_0x5bb2('0x1b')]?_0x3388b2[_0x5bb2('0x1b')][_0x5bb2('0x1c')]||null:null,'attributes':_0x3388b2[_0x5bb2('0x1b')]?_0x3388b2[_0x5bb2('0x1b')][_0x5bb2('0x1d')]||null:null,'include':_0x3388b2['options']?_0x3388b2[_0x5bb2('0x1b')][_0x5bb2('0x1f')]?_[_0x5bb2('0x20')](_0x3388b2['options']['include'],function(_0x440b2f){return{'model':db[_0x440b2f[_0x5bb2('0x21')]],'as':_0x440b2f['as'],'attributes':_0x440b2f[_0x5bb2('0x1d')],'include':_0x440b2f['include']?_[_0x5bb2('0x20')](_0x440b2f['include'],function(_0x54f80e){return{'model':db[_0x54f80e[_0x5bb2('0x21')]],'as':_0x54f80e['as'],'attributes':_0x54f80e[_0x5bb2('0x1d')],'include':_0x54f80e['include']?_[_0x5bb2('0x20')](_0x54f80e[_0x5bb2('0x1f')],function(_0x156d25){return{'model':db[_0x156d25[_0x5bb2('0x21')]],'as':_0x156d25['as'],'attributes':_0x156d25['attributes']};}):[]};}):[]};}):[]:[]})[_0x5bb2('0xd')](function(_0x321fd5){logger[_0x5bb2('0xe')]('ShowTrigger',_0x3388b2);logger[_0x5bb2('0x11')](_0x5bb2('0x23'),_0x3388b2,JSON[_0x5bb2('0x22')](_0x321fd5));_0x5bb07b(_0x321fd5);})[_0x5bb2('0x17')](function(_0x4de53f){logger[_0x5bb2('0x13')](_0x5bb2('0x23'),_0x4de53f[_0x5bb2('0x15')],_0x3388b2);_0xfd42ad(_0x14499d[_0x5bb2('0x13')](0x1f4,_0x4de53f['message']));});});};