c55332ec10c0e5149ce2597f91df66c8ce0f0615
[motion2.git] / server / config / utils.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 _0xe896=['isValidChannel','toLowerCase','clearBlockUser','isUndefined','blockedAt','updateAttributes','getLicense','role','then','catch','lodash','bluebird','../mysqldb','./license/util','chat','fax','sms','whatsapp','openchannel','getChannels'];(function(_0x385c76,_0xb97335){var _0x5c8367=function(_0xdfcd3){while(--_0xdfcd3){_0x385c76['push'](_0x385c76['shift']());}};_0x5c8367(++_0xb97335);}(_0xe896,0x96));var _0x6e89=function(_0xc2e451,_0x1e5681){_0xc2e451=_0xc2e451-0x0;var _0x3bc314=_0xe896[_0xc2e451];return _0x3bc314;};'use strict';var _=require(_0x6e89('0x0'));var BPromise=require(_0x6e89('0x1'));var db=require(_0x6e89('0x2'))['db'];var util=require(_0x6e89('0x3'));var channels=['voice','mail',_0x6e89('0x4'),_0x6e89('0x5'),_0x6e89('0x6'),_0x6e89('0x7'),_0x6e89('0x8')];exports[_0x6e89('0x9')]=function(){return channels;};exports[_0x6e89('0xa')]=function(_0x41562f){_0x41562f=_0x41562f[_0x6e89('0xb')]();return _['includes'](channels,_0x41562f);};exports[_0x6e89('0xc')]=function(_0x17934d,_0x456be6,_0xba00a9,_0x5c1d9b){var _0x18cb95={'loginAttempts':_0x456be6,'blocked':_0xba00a9};if(!_[_0x6e89('0xd')](_0x5c1d9b)){_0x18cb95[_0x6e89('0xe')]=_0x5c1d9b;}return _0x17934d[_0x6e89('0xf')](_0x18cb95);};exports[_0x6e89('0x10')]=function(_0x3fb22f){return new BPromise(function(_0x841465,_0x522384){var _0x37f7d5=0x0;if(_0x3fb22f[_0x6e89('0x11')]!=='agent'){_0x841465(_0x3fb22f);}db['User']['count']({'where':{'role':'agent','online':!![],'id':{'$ne':_0x3fb22f['id']}}})['then'](function(_0x2581fb){_0x37f7d5=_0x2581fb;return util[_0x6e89('0x10')]();})[_0x6e89('0x12')](function(_0x3f0fe9){if(_0x3f0fe9&&_0x3f0fe9['agents']&&_0x37f7d5>=_0x3f0fe9['agents']){throw Error('Maximum\x20login\x20has\x20been\x20reached');}_0x841465(_0x3fb22f);})[_0x6e89('0x13')](function(_0x363c3c){_0x522384(_0x363c3c);});});};