42e8268c69816a74d1c4ef1b45b2860f22b1a3d2
[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 _0x779b=['lodash','../mysqldb','./license/util','mail','chat','fax','sms','getChannels','isValidChannel','isUndefined','updateAttributes','getLicense','role','agent','User','count','then','catch'];(function(_0x1f7839,_0x2a26e6){var _0x36b42e=function(_0x553222){while(--_0x553222){_0x1f7839['push'](_0x1f7839['shift']());}};_0x36b42e(++_0x2a26e6);}(_0x779b,0x10e));var _0xb779=function(_0x55ac60,_0x105c71){_0x55ac60=_0x55ac60-0x0;var _0x8357d5=_0x779b[_0x55ac60];return _0x8357d5;};'use strict';var _=require(_0xb779('0x0'));var BPromise=require('bluebird');var db=require(_0xb779('0x1'))['db'];var util=require(_0xb779('0x2'));var channels=['voice',_0xb779('0x3'),_0xb779('0x4'),_0xb779('0x5'),_0xb779('0x6'),'whatsapp','openchannel'];exports[_0xb779('0x7')]=function(){return channels;};exports[_0xb779('0x8')]=function(_0xdf871a){_0xdf871a=_0xdf871a['toLowerCase']();return _['includes'](channels,_0xdf871a);};exports['clearBlockUser']=function(_0x2e32d8,_0x5bd51e,_0x109984,_0xf65665){var _0x2386e4={'loginAttempts':_0x5bd51e,'blocked':_0x109984};if(!_[_0xb779('0x9')](_0xf65665)){_0x2386e4['blockedAt']=_0xf65665;}return _0x2e32d8[_0xb779('0xa')](_0x2386e4);};exports[_0xb779('0xb')]=function(_0x16e89a){return new BPromise(function(_0x4a309,_0x58b082){var _0x5688ef=0x0;if(_0x16e89a[_0xb779('0xc')]!==_0xb779('0xd')){_0x4a309(_0x16e89a);}db[_0xb779('0xe')][_0xb779('0xf')]({'where':{'role':_0xb779('0xd'),'online':!![],'id':{'$ne':_0x16e89a['id']}}})['then'](function(_0x2beb0e){_0x5688ef=_0x2beb0e;return util[_0xb779('0xb')]();})[_0xb779('0x10')](function(_0x2c1dac){if(_0x2c1dac&&_0x2c1dac['agents']&&_0x5688ef>=_0x2c1dac['agents']){throw Error('Maximum\x20login\x20has\x20been\x20reached');}_0x4a309(_0x16e89a);})[_0xb779('0x11')](function(_0x448a4c){_0x58b082(_0x448a4c);});});};