893a1ac724a30e0c3cbbe3725db4a644cb058671
[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 _0xa35f=['whatsapp','openchannel','toLowerCase','isUndefined','updateAttributes','getLicense','role','agent','count','then','agents','Maximum\x20login\x20has\x20been\x20reached','lodash','bluebird','./license/util','voice','chat'];(function(_0x21c9f2,_0x5613c7){var _0x5703a8=function(_0xc054de){while(--_0xc054de){_0x21c9f2['push'](_0x21c9f2['shift']());}};_0x5703a8(++_0x5613c7);}(_0xa35f,0xa5));var _0xfa35=function(_0x3f2d02,_0x2c7deb){_0x3f2d02=_0x3f2d02-0x0;var _0x54092b=_0xa35f[_0x3f2d02];return _0x54092b;};'use strict';var _=require(_0xfa35('0x0'));var BPromise=require(_0xfa35('0x1'));var db=require('../mysqldb')['db'];var util=require(_0xfa35('0x2'));var channels=[_0xfa35('0x3'),'mail',_0xfa35('0x4'),'fax','sms',_0xfa35('0x5'),_0xfa35('0x6')];exports['getChannels']=function(){return channels;};exports['isValidChannel']=function(_0x7012c9){_0x7012c9=_0x7012c9[_0xfa35('0x7')]();return _['includes'](channels,_0x7012c9);};exports['clearBlockUser']=function(_0x1bf150,_0xe8286,_0x1641c5,_0xcdfdf2){var _0x37b037={'loginAttempts':_0xe8286,'blocked':_0x1641c5};if(!_[_0xfa35('0x8')](_0xcdfdf2)){_0x37b037['blockedAt']=_0xcdfdf2;}return _0x1bf150[_0xfa35('0x9')](_0x37b037);};exports[_0xfa35('0xa')]=function(_0x4cc366){return new BPromise(function(_0x166b05,_0x437147){var _0xf81c91=0x0;if(_0x4cc366[_0xfa35('0xb')]!==_0xfa35('0xc')){_0x166b05(_0x4cc366);}db['User'][_0xfa35('0xd')]({'where':{'role':'agent','online':!![],'id':{'$ne':_0x4cc366['id']}}})['then'](function(_0x100e7e){_0xf81c91=_0x100e7e;return util[_0xfa35('0xa')]();})[_0xfa35('0xe')](function(_0x25cfea){if(_0x25cfea&&_0x25cfea[_0xfa35('0xf')]&&_0xf81c91>=_0x25cfea[_0xfa35('0xf')]){throw Error(_0xfa35('0x10'));}_0x166b05(_0x4cc366);})['catch'](function(_0x2a496f){_0x437147(_0x2a496f);});});};