Built motion from commit 1ea47bf4.|2.6.34
[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 _0xc6c9=['stringify','catch','ShowTrunk','find','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','debug','Trunk,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','Trunk,\x20%s,\x20%s','result','Trunk','findAll','options','raw','where','attributes','limit','include','map','model','GetTrunk'];(function(_0x22789a,_0x4a1c8c){var _0xede88=function(_0x49243f){while(--_0x49243f){_0x22789a['push'](_0x22789a['shift']());}};_0xede88(++_0x4a1c8c);}(_0xc6c9,0x76));var _0x9c6c=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xc6c9[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x9c6c('0x0'));var util=require('util');var moment=require(_0x9c6c('0x1'));var BPromise=require(_0x9c6c('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x9c6c('0x3'));var db=require(_0x9c6c('0x4'))['db'];var utils=require(_0x9c6c('0x5'));var logger=require(_0x9c6c('0x6'))(_0x9c6c('0x7'));var config=require(_0x9c6c('0x8'));var jayson=require(_0x9c6c('0x9'));var client=jayson[_0x9c6c('0xa')][_0x9c6c('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x3b8a77,_0x1e7f03,_0x262fdf){return new BPromise(function(_0x5481ac,_0x1f0e2e){return client[_0x9c6c('0xc')](_0x3b8a77,_0x262fdf)[_0x9c6c('0xd')](function(_0xd61bc9){logger[_0x9c6c('0xe')]('Trunk,\x20%s,\x20%s',_0x1e7f03,'request\x20sent');logger[_0x9c6c('0xf')](_0x9c6c('0x10'),_0x1e7f03,_0x9c6c('0x11'),JSON['stringify'](_0xd61bc9));if(_0xd61bc9[_0x9c6c('0x12')]){if(_0xd61bc9[_0x9c6c('0x12')][_0x9c6c('0x13')]===0x1f4){logger[_0x9c6c('0x12')]('Trunk,\x20%s,\x20%s',_0x1e7f03,_0xd61bc9[_0x9c6c('0x12')][_0x9c6c('0x14')]);return _0x1f0e2e(_0xd61bc9[_0x9c6c('0x12')][_0x9c6c('0x14')]);}logger[_0x9c6c('0x12')]('Trunk,\x20%s,\x20%s',_0x1e7f03,_0xd61bc9[_0x9c6c('0x12')][_0x9c6c('0x14')]);return _0x5481ac(_0xd61bc9[_0x9c6c('0x12')][_0x9c6c('0x14')]);}else{logger['info'](_0x9c6c('0x15'),_0x1e7f03,_0x9c6c('0x11'));_0x5481ac(_0xd61bc9[_0x9c6c('0x16')][_0x9c6c('0x14')]);}})['catch'](function(_0xda51fc){logger['error']('Trunk,\x20%s,\x20%s',_0x1e7f03,_0xda51fc);_0x1f0e2e(_0xda51fc);});});}exports['GetTrunk']=function(_0x3b6e59){var _0x5716b0=this;return new Promise(function(_0x8beeb5,_0x5d1f94){return db[_0x9c6c('0x17')][_0x9c6c('0x18')]({'raw':_0x3b6e59[_0x9c6c('0x19')]?_0x3b6e59[_0x9c6c('0x19')][_0x9c6c('0x1a')]===undefined?!![]:![]:!![],'where':_0x3b6e59[_0x9c6c('0x19')]?_0x3b6e59[_0x9c6c('0x19')][_0x9c6c('0x1b')]||null:null,'attributes':_0x3b6e59[_0x9c6c('0x19')]?_0x3b6e59[_0x9c6c('0x19')][_0x9c6c('0x1c')]||null:null,'limit':_0x3b6e59[_0x9c6c('0x19')]?_0x3b6e59['options'][_0x9c6c('0x1d')]||null:null,'include':_0x3b6e59[_0x9c6c('0x19')]?_0x3b6e59[_0x9c6c('0x19')][_0x9c6c('0x1e')]?_[_0x9c6c('0x1f')](_0x3b6e59[_0x9c6c('0x19')]['include'],function(_0x20bb4c){return{'model':db[_0x20bb4c[_0x9c6c('0x20')]],'as':_0x20bb4c['as'],'attributes':_0x20bb4c[_0x9c6c('0x1c')],'include':_0x20bb4c[_0x9c6c('0x1e')]?_[_0x9c6c('0x1f')](_0x20bb4c['include'],function(_0x6db7d5){return{'model':db[_0x6db7d5[_0x9c6c('0x20')]],'as':_0x6db7d5['as'],'attributes':_0x6db7d5[_0x9c6c('0x1c')],'include':_0x6db7d5[_0x9c6c('0x1e')]?_['map'](_0x6db7d5['include'],function(_0xba8d83){return{'model':db[_0xba8d83[_0x9c6c('0x20')]],'as':_0xba8d83['as'],'attributes':_0xba8d83[_0x9c6c('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x180e7c){logger[_0x9c6c('0xe')](_0x9c6c('0x21'),_0x3b6e59);logger[_0x9c6c('0xf')]('GetTrunk',_0x3b6e59,JSON[_0x9c6c('0x22')](_0x180e7c));_0x8beeb5(_0x180e7c);})[_0x9c6c('0x23')](function(_0x206beb){logger[_0x9c6c('0x12')](_0x9c6c('0x21'),_0x206beb['message'],_0x3b6e59);_0x5d1f94(_0x5716b0['error'](0x1f4,_0x206beb[_0x9c6c('0x14')]));});});};exports[_0x9c6c('0x24')]=function(_0x31e77a){var _0x292777=this;return new Promise(function(_0x295896,_0x3f1680){return db[_0x9c6c('0x17')][_0x9c6c('0x25')]({'raw':_0x31e77a[_0x9c6c('0x19')]?_0x31e77a[_0x9c6c('0x19')][_0x9c6c('0x1a')]===undefined?!![]:![]:!![],'where':_0x31e77a[_0x9c6c('0x19')]?_0x31e77a[_0x9c6c('0x19')][_0x9c6c('0x1b')]||null:null,'attributes':_0x31e77a['options']?_0x31e77a[_0x9c6c('0x19')]['attributes']||null:null,'include':_0x31e77a[_0x9c6c('0x19')]?_0x31e77a['options'][_0x9c6c('0x1e')]?_[_0x9c6c('0x1f')](_0x31e77a[_0x9c6c('0x19')][_0x9c6c('0x1e')],function(_0x21c732){return{'model':db[_0x21c732[_0x9c6c('0x20')]],'as':_0x21c732['as'],'attributes':_0x21c732[_0x9c6c('0x1c')],'include':_0x21c732[_0x9c6c('0x1e')]?_[_0x9c6c('0x1f')](_0x21c732[_0x9c6c('0x1e')],function(_0x9afbe1){return{'model':db[_0x9afbe1['model']],'as':_0x9afbe1['as'],'attributes':_0x9afbe1['attributes'],'include':_0x9afbe1[_0x9c6c('0x1e')]?_[_0x9c6c('0x1f')](_0x9afbe1[_0x9c6c('0x1e')],function(_0x129e1e){return{'model':db[_0x129e1e[_0x9c6c('0x20')]],'as':_0x129e1e['as'],'attributes':_0x129e1e[_0x9c6c('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x3b2f67){logger[_0x9c6c('0xe')]('ShowTrunk',_0x31e77a);logger[_0x9c6c('0xf')]('ShowTrunk',_0x31e77a,JSON['stringify'](_0x3b2f67));_0x295896(_0x3b2f67);})[_0x9c6c('0x23')](function(_0x10cb8f){logger[_0x9c6c('0x12')]('ShowTrunk',_0x10cb8f[_0x9c6c('0x14')],_0x31e77a);_0x3f1680(_0x292777[_0x9c6c('0x12')](0x1f4,_0x10cb8f[_0x9c6c('0x14')]));});});};