0fec75333e833fc8f40ad22f0b2854f99062d7fc
[motion2.git] / server / api / interval / interval.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 _0x0067=['request','then','info','request\x20sent','debug','Interval,\x20%s,\x20%s,\x20%s','stringify','error','code','Interval,\x20%s,\x20%s','message','GetInterval','Interval','options','raw','where','include','map','model','attributes','catch','ShowInterval','find','lodash','util','moment','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http'];(function(_0x303064,_0x12f0c2){var _0x5a1d3d=function(_0x5b9d81){while(--_0x5b9d81){_0x303064['push'](_0x303064['shift']());}};_0x5a1d3d(++_0x12f0c2);}(_0x0067,0x1e5));var _0x7006=function(_0x699200,_0x39c101){_0x699200=_0x699200-0x0;var _0x266fd1=_0x0067[_0x699200];return _0x266fd1;};'use strict';var _=require(_0x7006('0x0'));var util=require(_0x7006('0x1'));var moment=require(_0x7006('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x7006('0x3'))['db'];var utils=require(_0x7006('0x4'));var logger=require(_0x7006('0x5'))(_0x7006('0x6'));var config=require('../../config/environment');var jayson=require(_0x7006('0x7'));var client=jayson[_0x7006('0x8')][_0x7006('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x1b955c,_0x431f9a,_0xc0f266){return new BPromise(function(_0x1f5319,_0x48648b){return client[_0x7006('0xa')](_0x1b955c,_0xc0f266)[_0x7006('0xb')](function(_0x7c8d6a){logger[_0x7006('0xc')]('Interval,\x20%s,\x20%s',_0x431f9a,_0x7006('0xd'));logger[_0x7006('0xe')](_0x7006('0xf'),_0x431f9a,_0x7006('0xd'),JSON[_0x7006('0x10')](_0x7c8d6a));if(_0x7c8d6a[_0x7006('0x11')]){if(_0x7c8d6a[_0x7006('0x11')][_0x7006('0x12')]===0x1f4){logger['error'](_0x7006('0x13'),_0x431f9a,_0x7c8d6a[_0x7006('0x11')]['message']);return _0x48648b(_0x7c8d6a[_0x7006('0x11')][_0x7006('0x14')]);}logger['error']('Interval,\x20%s,\x20%s',_0x431f9a,_0x7c8d6a[_0x7006('0x11')]['message']);return _0x1f5319(_0x7c8d6a[_0x7006('0x11')]['message']);}else{logger[_0x7006('0xc')](_0x7006('0x13'),_0x431f9a,_0x7006('0xd'));_0x1f5319(_0x7c8d6a['result'][_0x7006('0x14')]);}})['catch'](function(_0x9842fb){logger['error'](_0x7006('0x13'),_0x431f9a,_0x9842fb);_0x48648b(_0x9842fb);});});}exports[_0x7006('0x15')]=function(_0x542815){var _0x2b5d78=this;return new Promise(function(_0x5e8bfe,_0x52fe5a){return db[_0x7006('0x16')]['findAll']({'raw':_0x542815[_0x7006('0x17')]?_0x542815[_0x7006('0x17')][_0x7006('0x18')]===undefined?!![]:![]:!![],'where':_0x542815[_0x7006('0x17')]?_0x542815[_0x7006('0x17')][_0x7006('0x19')]||null:null,'attributes':_0x542815['options']?_0x542815[_0x7006('0x17')]['attributes']||null:null,'limit':_0x542815[_0x7006('0x17')]?_0x542815[_0x7006('0x17')]['limit']||null:null,'include':_0x542815[_0x7006('0x17')]?_0x542815['options'][_0x7006('0x1a')]?_[_0x7006('0x1b')](_0x542815[_0x7006('0x17')][_0x7006('0x1a')],function(_0x116c5a){return{'model':db[_0x116c5a[_0x7006('0x1c')]],'as':_0x116c5a['as'],'attributes':_0x116c5a[_0x7006('0x1d')],'include':_0x116c5a[_0x7006('0x1a')]?_['map'](_0x116c5a['include'],function(_0x49e9d5){return{'model':db[_0x49e9d5['model']],'as':_0x49e9d5['as'],'attributes':_0x49e9d5[_0x7006('0x1d')],'include':_0x49e9d5[_0x7006('0x1a')]?_[_0x7006('0x1b')](_0x49e9d5[_0x7006('0x1a')],function(_0x439973){return{'model':db[_0x439973[_0x7006('0x1c')]],'as':_0x439973['as'],'attributes':_0x439973[_0x7006('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x7006('0xb')](function(_0xc6fc31){logger[_0x7006('0xc')]('GetInterval',_0x542815);logger[_0x7006('0xe')]('GetInterval',_0x542815,JSON['stringify'](_0xc6fc31));_0x5e8bfe(_0xc6fc31);})[_0x7006('0x1e')](function(_0x50c67e){logger[_0x7006('0x11')](_0x7006('0x15'),_0x50c67e[_0x7006('0x14')],_0x542815);_0x52fe5a(_0x2b5d78[_0x7006('0x11')](0x1f4,_0x50c67e[_0x7006('0x14')]));});});};exports[_0x7006('0x1f')]=function(_0x21e5b1){var _0x5714ce=this;return new Promise(function(_0x42725c,_0x823e35){return db['Interval'][_0x7006('0x20')]({'raw':_0x21e5b1[_0x7006('0x17')]?_0x21e5b1[_0x7006('0x17')][_0x7006('0x18')]===undefined?!![]:![]:!![],'where':_0x21e5b1[_0x7006('0x17')]?_0x21e5b1[_0x7006('0x17')][_0x7006('0x19')]||null:null,'attributes':_0x21e5b1[_0x7006('0x17')]?_0x21e5b1['options']['attributes']||null:null,'include':_0x21e5b1[_0x7006('0x17')]?_0x21e5b1['options'][_0x7006('0x1a')]?_[_0x7006('0x1b')](_0x21e5b1['options'][_0x7006('0x1a')],function(_0x84a2f5){return{'model':db[_0x84a2f5[_0x7006('0x1c')]],'as':_0x84a2f5['as'],'attributes':_0x84a2f5[_0x7006('0x1d')],'include':_0x84a2f5[_0x7006('0x1a')]?_[_0x7006('0x1b')](_0x84a2f5['include'],function(_0x1f324a){return{'model':db[_0x1f324a['model']],'as':_0x1f324a['as'],'attributes':_0x1f324a[_0x7006('0x1d')],'include':_0x1f324a['include']?_[_0x7006('0x1b')](_0x1f324a[_0x7006('0x1a')],function(_0x9a1949){return{'model':db[_0x9a1949[_0x7006('0x1c')]],'as':_0x9a1949['as'],'attributes':_0x9a1949['attributes']};}):[]};}):[]};}):[]:[]})[_0x7006('0xb')](function(_0x46a273){logger[_0x7006('0xc')](_0x7006('0x1f'),_0x21e5b1);logger['debug'](_0x7006('0x1f'),_0x21e5b1,JSON[_0x7006('0x10')](_0x46a273));_0x42725c(_0x46a273);})['catch'](function(_0x34dce1){logger['error'](_0x7006('0x1f'),_0x34dce1[_0x7006('0x14')],_0x21e5b1);_0x823e35(_0x5714ce['error'](0x1f4,_0x34dce1[_0x7006('0x14')]));});});};