c80683670b62059615f3fc362fae286b60cf7ad7
[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 _0xda3c=['bluebird','../mysqldb','./license/util','voice','sms','whatsapp','openchannel','getChannels','toLowerCase','includes','clearBlockUser','isUndefined','blockedAt','updateAttributes','getLicense','User','count','agent','then','agents','Maximum\x20login\x20has\x20been\x20reached','catch','lodash'];(function(_0x53cf8e,_0x3d290f){var _0x459197=function(_0x67073c){while(--_0x67073c){_0x53cf8e['push'](_0x53cf8e['shift']());}};_0x459197(++_0x3d290f);}(_0xda3c,0x1cb));var _0xcda3=function(_0x40a045,_0x516f0e){_0x40a045=_0x40a045-0x0;var _0x1a687c=_0xda3c[_0x40a045];return _0x1a687c;};'use strict';var _=require(_0xcda3('0x0'));var BPromise=require(_0xcda3('0x1'));var db=require(_0xcda3('0x2'))['db'];var util=require(_0xcda3('0x3'));var channels=[_0xcda3('0x4'),'mail','chat','fax',_0xcda3('0x5'),_0xcda3('0x6'),_0xcda3('0x7')];exports[_0xcda3('0x8')]=function(){return channels;};exports['isValidChannel']=function(_0x4adb1d){_0x4adb1d=_0x4adb1d[_0xcda3('0x9')]();return _[_0xcda3('0xa')](channels,_0x4adb1d);};exports[_0xcda3('0xb')]=function(_0x12c9d4,_0x9ea3f6,_0x25eea7,_0x48f068){var _0x17d1e9={'loginAttempts':_0x9ea3f6,'blocked':_0x25eea7};if(!_[_0xcda3('0xc')](_0x48f068)){_0x17d1e9[_0xcda3('0xd')]=_0x48f068;}return _0x12c9d4[_0xcda3('0xe')](_0x17d1e9);};exports[_0xcda3('0xf')]=function(_0x25a2c4){return new BPromise(function(_0x3d404a,_0x2face9){var _0x233e9d=0x0;if(_0x25a2c4['role']!=='agent'){_0x3d404a(_0x25a2c4);}db[_0xcda3('0x10')][_0xcda3('0x11')]({'where':{'role':_0xcda3('0x12'),'online':!![],'id':{'$ne':_0x25a2c4['id']}}})[_0xcda3('0x13')](function(_0x4d25ce){_0x233e9d=_0x4d25ce;return util['getLicense']();})[_0xcda3('0x13')](function(_0x32eb93){if(_0x32eb93&&_0x32eb93[_0xcda3('0x14')]&&_0x233e9d>=_0x32eb93[_0xcda3('0x14')]){throw Error(_0xcda3('0x15'));}_0x3d404a(_0x25a2c4);})[_0xcda3('0x16')](function(_0x4e1978){_0x2face9(_0x4e1978);});});};