Built motion from commit 47436d59.|2.6.7
[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 _0x30c5=['chat','fax','whatsapp','getChannels','isValidChannel','toLowerCase','includes','clearBlockUser','isUndefined','updateAttributes','role','agent','User','count','then','getLicense','agents','Maximum\x20login\x20has\x20been\x20reached','catch','lodash','bluebird','./license/util','voice','mail'];(function(_0xc19641,_0x2eb5c6){var _0x507ad1=function(_0x1d4050){while(--_0x1d4050){_0xc19641['push'](_0xc19641['shift']());}};_0x507ad1(++_0x2eb5c6);}(_0x30c5,0x14b));var _0x530c=function(_0x5ddb1c,_0x5ea4df){_0x5ddb1c=_0x5ddb1c-0x0;var _0x354adc=_0x30c5[_0x5ddb1c];return _0x354adc;};'use strict';var _=require(_0x530c('0x0'));var BPromise=require(_0x530c('0x1'));var db=require('../mysqldb')['db'];var util=require(_0x530c('0x2'));var channels=[_0x530c('0x3'),_0x530c('0x4'),_0x530c('0x5'),_0x530c('0x6'),'sms',_0x530c('0x7'),'openchannel'];exports[_0x530c('0x8')]=function(){return channels;};exports[_0x530c('0x9')]=function(_0x802966){_0x802966=_0x802966[_0x530c('0xa')]();return _[_0x530c('0xb')](channels,_0x802966);};exports[_0x530c('0xc')]=function(_0x1fb285,_0x2653a9,_0x2e0e01,_0x40a19a){var _0x488ad4={'loginAttempts':_0x2653a9,'blocked':_0x2e0e01};if(!_[_0x530c('0xd')](_0x40a19a)){_0x488ad4['blockedAt']=_0x40a19a;}return _0x1fb285[_0x530c('0xe')](_0x488ad4);};exports['getLicense']=function(_0x216f5f){return new BPromise(function(_0x26863c,_0x281be2){var _0x1c3ae1=0x0;if(_0x216f5f[_0x530c('0xf')]!==_0x530c('0x10')){_0x26863c(_0x216f5f);}db[_0x530c('0x11')][_0x530c('0x12')]({'where':{'role':'agent','online':!![],'id':{'$ne':_0x216f5f['id']}}})[_0x530c('0x13')](function(_0x18267a){_0x1c3ae1=_0x18267a;return util[_0x530c('0x14')]();})[_0x530c('0x13')](function(_0x3bb98b){if(_0x3bb98b&&_0x3bb98b['agents']&&_0x1c3ae1>=_0x3bb98b[_0x530c('0x15')]){throw Error(_0x530c('0x16'));}_0x26863c(_0x216f5f);})[_0x530c('0x17')](function(_0x591ee4){_0x281be2(_0x591ee4);});});};