d221695f872f7a1b3aba07f04a5f4a5d48150a37
[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 _0x89cc=['openchannel','getChannels','toLowerCase','clearBlockUser','isUndefined','updateAttributes','getLicense','role','User','count','agent','then','agents','Maximum\x20login\x20has\x20been\x20reached','catch','lodash','bluebird','./license/util','voice','mail','chat','sms','whatsapp'];(function(_0xc95eba,_0x526674){var _0x2595b7=function(_0x58bf3e){while(--_0x58bf3e){_0xc95eba['push'](_0xc95eba['shift']());}};_0x2595b7(++_0x526674);}(_0x89cc,0xb0));var _0xc89c=function(_0x240e3f,_0x58da80){_0x240e3f=_0x240e3f-0x0;var _0x563724=_0x89cc[_0x240e3f];return _0x563724;};'use strict';var _=require(_0xc89c('0x0'));var BPromise=require(_0xc89c('0x1'));var db=require('../mysqldb')['db'];var util=require(_0xc89c('0x2'));var channels=[_0xc89c('0x3'),_0xc89c('0x4'),_0xc89c('0x5'),'fax',_0xc89c('0x6'),_0xc89c('0x7'),_0xc89c('0x8')];exports[_0xc89c('0x9')]=function(){return channels;};exports['isValidChannel']=function(_0x4b05ad){_0x4b05ad=_0x4b05ad[_0xc89c('0xa')]();return _['includes'](channels,_0x4b05ad);};exports[_0xc89c('0xb')]=function(_0x878607,_0x353dd1,_0x4ca64d,_0x596e7a){var _0x20485b={'loginAttempts':_0x353dd1,'blocked':_0x4ca64d};if(!_[_0xc89c('0xc')](_0x596e7a)){_0x20485b['blockedAt']=_0x596e7a;}return _0x878607[_0xc89c('0xd')](_0x20485b);};exports[_0xc89c('0xe')]=function(_0x5ec9e4){return new BPromise(function(_0x18bca1,_0x2ea946){var _0x5e2f95=0x0;if(_0x5ec9e4[_0xc89c('0xf')]!=='agent'){_0x18bca1(_0x5ec9e4);}db[_0xc89c('0x10')][_0xc89c('0x11')]({'where':{'role':_0xc89c('0x12'),'online':!![],'id':{'$ne':_0x5ec9e4['id']}}})[_0xc89c('0x13')](function(_0x30b037){_0x5e2f95=_0x30b037;return util[_0xc89c('0xe')]();})[_0xc89c('0x13')](function(_0x5c2bfb){if(_0x5c2bfb&&_0x5c2bfb[_0xc89c('0x14')]&&_0x5e2f95>=_0x5c2bfb[_0xc89c('0x14')]){throw Error(_0xc89c('0x15'));}_0x18bca1(_0x5ec9e4);})[_0xc89c('0x16')](function(_0x14e4f9){_0x2ea946(_0x14e4f9);});});};