Built motion from commit e0fa946e.|2.6.5
[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 _0xb481=['isValidChannel','includes','clearBlockUser','isUndefined','updateAttributes','getLicense','agent','count','then','agents','Maximum\x20login\x20has\x20been\x20reached','catch','lodash','./license/util','chat','sms','whatsapp','openchannel','getChannels'];(function(_0x5e1b91,_0x236f17){var _0x59b52f=function(_0x5c05ed){while(--_0x5c05ed){_0x5e1b91['push'](_0x5e1b91['shift']());}};_0x59b52f(++_0x236f17);}(_0xb481,0x19b));var _0x1b48=function(_0x573dcc,_0x2888ae){_0x573dcc=_0x573dcc-0x0;var _0x3bc335=_0xb481[_0x573dcc];return _0x3bc335;};'use strict';var _=require(_0x1b48('0x0'));var BPromise=require('bluebird');var db=require('../mysqldb')['db'];var util=require(_0x1b48('0x1'));var channels=['voice','mail',_0x1b48('0x2'),'fax',_0x1b48('0x3'),_0x1b48('0x4'),_0x1b48('0x5')];exports[_0x1b48('0x6')]=function(){return channels;};exports[_0x1b48('0x7')]=function(_0x4dedc0){_0x4dedc0=_0x4dedc0['toLowerCase']();return _[_0x1b48('0x8')](channels,_0x4dedc0);};exports[_0x1b48('0x9')]=function(_0x35093f,_0x97c221,_0x7e4e44,_0x995a6a){var _0x5ec889={'loginAttempts':_0x97c221,'blocked':_0x7e4e44};if(!_[_0x1b48('0xa')](_0x995a6a)){_0x5ec889['blockedAt']=_0x995a6a;}return _0x35093f[_0x1b48('0xb')](_0x5ec889);};exports[_0x1b48('0xc')]=function(_0x2ea516){return new BPromise(function(_0x3cc730,_0x4f8804){var _0x10e49b=0x0;if(_0x2ea516['role']!==_0x1b48('0xd')){_0x3cc730(_0x2ea516);}db['User'][_0x1b48('0xe')]({'where':{'role':_0x1b48('0xd'),'online':!![],'id':{'$ne':_0x2ea516['id']}}})[_0x1b48('0xf')](function(_0x1b211e){_0x10e49b=_0x1b211e;return util[_0x1b48('0xc')]();})[_0x1b48('0xf')](function(_0x580d60){if(_0x580d60&&_0x580d60[_0x1b48('0x10')]&&_0x10e49b>=_0x580d60['agents']){throw Error(_0x1b48('0x11'));}_0x3cc730(_0x2ea516);})[_0x1b48('0x12')](function(_0x1d7cb1){_0x4f8804(_0x1d7cb1);});});};