b22c5da294cb6dbf7141755e27071ac61fe2cdc8
[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 _0x9e94=['updateAttributes','getLicense','role','agent','User','count','then','agents','catch','lodash','bluebird','../mysqldb','./license/util','mail','chat','fax','getChannels','includes','clearBlockUser','isUndefined','blockedAt'];(function(_0xfbdece,_0x4bc32d){var _0x4b2026=function(_0x46c7c4){while(--_0x46c7c4){_0xfbdece['push'](_0xfbdece['shift']());}};_0x4b2026(++_0x4bc32d);}(_0x9e94,0x198));var _0x49e9=function(_0x45e1da,_0x116d65){_0x45e1da=_0x45e1da-0x0;var _0x399cb=_0x9e94[_0x45e1da];return _0x399cb;};'use strict';var _=require(_0x49e9('0x0'));var BPromise=require(_0x49e9('0x1'));var db=require(_0x49e9('0x2'))['db'];var util=require(_0x49e9('0x3'));var channels=['voice',_0x49e9('0x4'),_0x49e9('0x5'),_0x49e9('0x6'),'sms','whatsapp','openchannel'];exports[_0x49e9('0x7')]=function(){return channels;};exports['isValidChannel']=function(_0x3debeb){_0x3debeb=_0x3debeb['toLowerCase']();return _[_0x49e9('0x8')](channels,_0x3debeb);};exports[_0x49e9('0x9')]=function(_0x1afc2e,_0x55d582,_0x3d0749,_0x267ca2){var _0x599368={'loginAttempts':_0x55d582,'blocked':_0x3d0749};if(!_[_0x49e9('0xa')](_0x267ca2)){_0x599368[_0x49e9('0xb')]=_0x267ca2;}return _0x1afc2e[_0x49e9('0xc')](_0x599368);};exports[_0x49e9('0xd')]=function(_0x2d3903){return new BPromise(function(_0x25de6b,_0x195185){var _0xbe6525=0x0;if(_0x2d3903[_0x49e9('0xe')]!==_0x49e9('0xf')){_0x25de6b(_0x2d3903);}db[_0x49e9('0x10')][_0x49e9('0x11')]({'where':{'role':_0x49e9('0xf'),'online':!![],'id':{'$ne':_0x2d3903['id']}}})['then'](function(_0x28c0c7){_0xbe6525=_0x28c0c7;return util['getLicense']();})[_0x49e9('0x12')](function(_0x3730f7){if(_0x3730f7&&_0x3730f7[_0x49e9('0x13')]&&_0xbe6525>=_0x3730f7[_0x49e9('0x13')]){throw Error('Maximum\x20login\x20has\x20been\x20reached');}_0x25de6b(_0x2d3903);})[_0x49e9('0x14')](function(_0x56b992){_0x195185(_0x56b992);});});};