Built motion from commit (unavailable).|2.6.0
[motion2.git] / server / api / userVoiceQueueRt / userVoiceQueueRt.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 _0x6640=['UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetVoiceQueueRtPauses','findAll','options','where','sequelize','debug','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','socket.io-emitter','request','then'];(function(_0x3e2045,_0x715da4){var _0x36d4c2=function(_0x14e418){while(--_0x14e418){_0x3e2045['push'](_0x3e2045['shift']());}};_0x36d4c2(++_0x715da4);}(_0x6640,0x97));var _0x0664=function(_0x47de9a,_0x40cf23){_0x47de9a=_0x47de9a-0x0;var _0x4b9d6c=_0x6640[_0x47de9a];return _0x4b9d6c;};'use strict';var _=require(_0x0664('0x0'));var util=require(_0x0664('0x1'));var moment=require(_0x0664('0x2'));var BPromise=require(_0x0664('0x3'));var rs=require(_0x0664('0x4'));var fs=require('fs');var Redis=require(_0x0664('0x5'));var db=require(_0x0664('0x6'))['db'];var utils=require(_0x0664('0x7'));var logger=require(_0x0664('0x8'))(_0x0664('0x9'));var config=require(_0x0664('0xa'));var jayson=require(_0x0664('0xb'));var client=jayson[_0x0664('0xc')][_0x0664('0xd')]({'port':0x232a});config[_0x0664('0xe')]=_[_0x0664('0xf')](config[_0x0664('0xe')],{'host':'localhost','port':0x18eb});var socket=require(_0x0664('0x10'))(new Redis(config[_0x0664('0xe')]));require('./userVoiceQueueRt.socket')['register'](socket);function respondWithRpcPromise(_0x17c0a0,_0x5d33e0,_0x4db11b){return new BPromise(function(_0x560d77,_0x51a1ca){return client[_0x0664('0x11')](_0x17c0a0,_0x4db11b)[_0x0664('0x12')](function(_0x4d0646){logger['info'](_0x0664('0x13'),_0x5d33e0,_0x0664('0x14'));logger['debug'](_0x0664('0x15'),_0x5d33e0,'request\x20sent',JSON[_0x0664('0x16')](_0x4d0646));if(_0x4d0646[_0x0664('0x17')]){if(_0x4d0646['error'][_0x0664('0x18')]===0x1f4){logger[_0x0664('0x17')](_0x0664('0x13'),_0x5d33e0,_0x4d0646[_0x0664('0x17')][_0x0664('0x19')]);return _0x51a1ca(_0x4d0646[_0x0664('0x17')][_0x0664('0x19')]);}logger[_0x0664('0x17')](_0x0664('0x13'),_0x5d33e0,_0x4d0646['error'][_0x0664('0x19')]);return _0x560d77(_0x4d0646['error'][_0x0664('0x19')]);}else{logger['info'](_0x0664('0x13'),_0x5d33e0,_0x0664('0x14'));_0x560d77(_0x4d0646[_0x0664('0x1a')]['message']);}})[_0x0664('0x1b')](function(_0x4d8fab){logger['error'](_0x0664('0x13'),_0x5d33e0,_0x4d8fab);_0x51a1ca(_0x4d8fab);});});}exports[_0x0664('0x1c')]=function(_0x47c9b9){var _0x570c84=this;return new Promise(function(_0x16e804,_0x410286){return db['UserVoiceQueueRt'][_0x0664('0x1d')]({'raw':_0x47c9b9['options']?_0x47c9b9['options']['raw']===undefined?!![]:![]:!![],'where':_0x47c9b9[_0x0664('0x1e')]?_0x47c9b9['options'][_0x0664('0x1f')]||null:null,'attributes':[[db[_0x0664('0x20')]['fn']('COUNT',db[_0x0664('0x20')]['fn']('IF',db['sequelize']['literal']('`paused`\x20=\x201,\x201,\x20null'))),'outboundQueuePauses']]})[_0x0664('0x12')](function(_0x414548){logger['info'](_0x0664('0x1c'),_0x47c9b9);logger[_0x0664('0x21')](_0x0664('0x1c'),_0x47c9b9,JSON[_0x0664('0x16')](_0x414548));_0x16e804(_0x414548);})['catch'](function(_0x1b35d7){logger[_0x0664('0x17')](_0x0664('0x1c'),_0x1b35d7[_0x0664('0x19')],_0x47c9b9);_0x410286(_0x570c84[_0x0664('0x17')](0x1f4,_0x1b35d7[_0x0664('0x19')]));});});};