Built motion from commit f8768ebe.|2.6.15
[motion2.git] / server / api / trunk / trunk.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 _0xfbf1=['then','info','Trunk,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','GetTrunk','Trunk','findAll','options','raw','where','attributes','limit','include','map','model','ShowTrunk','find','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','request'];(function(_0x4ea69d,_0x290f53){var _0x5318e0=function(_0x18e081){while(--_0x18e081){_0x4ea69d['push'](_0x4ea69d['shift']());}};_0x5318e0(++_0x290f53);}(_0xfbf1,0xa8));var _0x1fbf=function(_0x59e86d,_0x220320){_0x59e86d=_0x59e86d-0x0;var _0xa22e60=_0xfbf1[_0x59e86d];return _0xa22e60;};'use strict';var _=require(_0x1fbf('0x0'));var util=require('util');var moment=require(_0x1fbf('0x1'));var BPromise=require(_0x1fbf('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x1fbf('0x3'));var db=require(_0x1fbf('0x4'))['db'];var utils=require(_0x1fbf('0x5'));var logger=require(_0x1fbf('0x6'))(_0x1fbf('0x7'));var config=require(_0x1fbf('0x8'));var jayson=require(_0x1fbf('0x9'));var client=jayson['client'][_0x1fbf('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x5efa20,_0x353cc8,_0x3133c3){return new BPromise(function(_0xc414ae,_0x3ad871){return client[_0x1fbf('0xb')](_0x5efa20,_0x3133c3)[_0x1fbf('0xc')](function(_0x303979){logger[_0x1fbf('0xd')](_0x1fbf('0xe'),_0x353cc8,_0x1fbf('0xf'));logger[_0x1fbf('0x10')]('Trunk,\x20%s,\x20%s,\x20%s',_0x353cc8,'request\x20sent',JSON[_0x1fbf('0x11')](_0x303979));if(_0x303979[_0x1fbf('0x12')]){if(_0x303979[_0x1fbf('0x12')][_0x1fbf('0x13')]===0x1f4){logger[_0x1fbf('0x12')](_0x1fbf('0xe'),_0x353cc8,_0x303979[_0x1fbf('0x12')][_0x1fbf('0x14')]);return _0x3ad871(_0x303979[_0x1fbf('0x12')]['message']);}logger[_0x1fbf('0x12')](_0x1fbf('0xe'),_0x353cc8,_0x303979[_0x1fbf('0x12')][_0x1fbf('0x14')]);return _0xc414ae(_0x303979[_0x1fbf('0x12')][_0x1fbf('0x14')]);}else{logger['info'](_0x1fbf('0xe'),_0x353cc8,_0x1fbf('0xf'));_0xc414ae(_0x303979[_0x1fbf('0x15')][_0x1fbf('0x14')]);}})[_0x1fbf('0x16')](function(_0x48557e){logger[_0x1fbf('0x12')]('Trunk,\x20%s,\x20%s',_0x353cc8,_0x48557e);_0x3ad871(_0x48557e);});});}exports[_0x1fbf('0x17')]=function(_0x23857e){var _0x2eca3b=this;return new Promise(function(_0x43a34c,_0x2270d6){return db[_0x1fbf('0x18')][_0x1fbf('0x19')]({'raw':_0x23857e[_0x1fbf('0x1a')]?_0x23857e[_0x1fbf('0x1a')][_0x1fbf('0x1b')]===undefined?!![]:![]:!![],'where':_0x23857e['options']?_0x23857e[_0x1fbf('0x1a')][_0x1fbf('0x1c')]||null:null,'attributes':_0x23857e[_0x1fbf('0x1a')]?_0x23857e[_0x1fbf('0x1a')][_0x1fbf('0x1d')]||null:null,'limit':_0x23857e[_0x1fbf('0x1a')]?_0x23857e['options'][_0x1fbf('0x1e')]||null:null,'include':_0x23857e['options']?_0x23857e[_0x1fbf('0x1a')][_0x1fbf('0x1f')]?_[_0x1fbf('0x20')](_0x23857e[_0x1fbf('0x1a')][_0x1fbf('0x1f')],function(_0x388cda){return{'model':db[_0x388cda[_0x1fbf('0x21')]],'as':_0x388cda['as'],'attributes':_0x388cda[_0x1fbf('0x1d')],'include':_0x388cda[_0x1fbf('0x1f')]?_[_0x1fbf('0x20')](_0x388cda['include'],function(_0x3acc5b){return{'model':db[_0x3acc5b[_0x1fbf('0x21')]],'as':_0x3acc5b['as'],'attributes':_0x3acc5b[_0x1fbf('0x1d')],'include':_0x3acc5b['include']?_['map'](_0x3acc5b[_0x1fbf('0x1f')],function(_0x58507a){return{'model':db[_0x58507a['model']],'as':_0x58507a['as'],'attributes':_0x58507a[_0x1fbf('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x308cb4){logger[_0x1fbf('0xd')](_0x1fbf('0x17'),_0x23857e);logger[_0x1fbf('0x10')](_0x1fbf('0x17'),_0x23857e,JSON['stringify'](_0x308cb4));_0x43a34c(_0x308cb4);})[_0x1fbf('0x16')](function(_0x149603){logger[_0x1fbf('0x12')](_0x1fbf('0x17'),_0x149603[_0x1fbf('0x14')],_0x23857e);_0x2270d6(_0x2eca3b['error'](0x1f4,_0x149603[_0x1fbf('0x14')]));});});};exports[_0x1fbf('0x22')]=function(_0x116d77){var _0x32965d=this;return new Promise(function(_0x55939f,_0x322c01){return db[_0x1fbf('0x18')][_0x1fbf('0x23')]({'raw':_0x116d77[_0x1fbf('0x1a')]?_0x116d77['options'][_0x1fbf('0x1b')]===undefined?!![]:![]:!![],'where':_0x116d77[_0x1fbf('0x1a')]?_0x116d77[_0x1fbf('0x1a')][_0x1fbf('0x1c')]||null:null,'attributes':_0x116d77[_0x1fbf('0x1a')]?_0x116d77[_0x1fbf('0x1a')][_0x1fbf('0x1d')]||null:null,'include':_0x116d77[_0x1fbf('0x1a')]?_0x116d77[_0x1fbf('0x1a')][_0x1fbf('0x1f')]?_[_0x1fbf('0x20')](_0x116d77[_0x1fbf('0x1a')][_0x1fbf('0x1f')],function(_0x523e21){return{'model':db[_0x523e21[_0x1fbf('0x21')]],'as':_0x523e21['as'],'attributes':_0x523e21['attributes'],'include':_0x523e21[_0x1fbf('0x1f')]?_[_0x1fbf('0x20')](_0x523e21[_0x1fbf('0x1f')],function(_0x40137c){return{'model':db[_0x40137c[_0x1fbf('0x21')]],'as':_0x40137c['as'],'attributes':_0x40137c[_0x1fbf('0x1d')],'include':_0x40137c[_0x1fbf('0x1f')]?_[_0x1fbf('0x20')](_0x40137c[_0x1fbf('0x1f')],function(_0x95761e){return{'model':db[_0x95761e[_0x1fbf('0x21')]],'as':_0x95761e['as'],'attributes':_0x95761e[_0x1fbf('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x1fbf('0xc')](function(_0x3c8111){logger[_0x1fbf('0xd')](_0x1fbf('0x22'),_0x116d77);logger[_0x1fbf('0x10')]('ShowTrunk',_0x116d77,JSON['stringify'](_0x3c8111));_0x55939f(_0x3c8111);})['catch'](function(_0x3a98fc){logger[_0x1fbf('0x12')]('ShowTrunk',_0x3a98fc[_0x1fbf('0x14')],_0x116d77);_0x322c01(_0x32965d[_0x1fbf('0x12')](0x1f4,_0x3a98fc['message']));});});};