21018f7498927ad021022213caf5feed675e0b2c
[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 _0xa9e8=['voice','chat','fax','sms','whatsapp','openchannel','getChannels','isValidChannel','includes','clearBlockUser','updateAttributes','User','count','then','getLicense','Maximum\x20login\x20has\x20been\x20reached','catch','lodash','bluebird','../mysqldb','./license/util'];(function(_0x37cc52,_0x459a9b){var _0x2b4a90=function(_0xabcfc7){while(--_0xabcfc7){_0x37cc52['push'](_0x37cc52['shift']());}};_0x2b4a90(++_0x459a9b);}(_0xa9e8,0xe3));var _0x8a9e=function(_0x4768dc,_0x2f5014){_0x4768dc=_0x4768dc-0x0;var _0x1c75cc=_0xa9e8[_0x4768dc];return _0x1c75cc;};'use strict';var _=require(_0x8a9e('0x0'));var BPromise=require(_0x8a9e('0x1'));var db=require(_0x8a9e('0x2'))['db'];var util=require(_0x8a9e('0x3'));var channels=[_0x8a9e('0x4'),'mail',_0x8a9e('0x5'),_0x8a9e('0x6'),_0x8a9e('0x7'),_0x8a9e('0x8'),_0x8a9e('0x9')];exports[_0x8a9e('0xa')]=function(){return channels;};exports[_0x8a9e('0xb')]=function(_0x27b2fb){_0x27b2fb=_0x27b2fb['toLowerCase']();return _[_0x8a9e('0xc')](channels,_0x27b2fb);};exports[_0x8a9e('0xd')]=function(_0x1efdf9,_0x15275f,_0x389ea7,_0x590cfe){var _0x6c62ee={'loginAttempts':_0x15275f,'blocked':_0x389ea7};if(!_['isUndefined'](_0x590cfe)){_0x6c62ee['blockedAt']=_0x590cfe;}return _0x1efdf9[_0x8a9e('0xe')](_0x6c62ee);};exports['getLicense']=function(_0x4e2a9f){return new BPromise(function(_0x184923,_0x86fc92){var _0x4af8b5=0x0;if(_0x4e2a9f['role']!=='agent'){_0x184923(_0x4e2a9f);}db[_0x8a9e('0xf')][_0x8a9e('0x10')]({'where':{'role':'agent','online':!![],'id':{'$ne':_0x4e2a9f['id']}}})[_0x8a9e('0x11')](function(_0x1c283f){_0x4af8b5=_0x1c283f;return util[_0x8a9e('0x12')]();})[_0x8a9e('0x11')](function(_0x807780){if(_0x807780&&_0x807780['agents']&&_0x4af8b5>=_0x807780['agents']){throw Error(_0x8a9e('0x13'));}_0x184923(_0x4e2a9f);})[_0x8a9e('0x14')](function(_0x26ee35){_0x86fc92(_0x26ee35);});});};