Built motion from commit e6806ed6.|2.6.0
[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 _0x48a0=['blockedAt','updateAttributes','role','agent','User','count','then','getLicense','agents','Maximum\x20login\x20has\x20been\x20reached','catch','lodash','../mysqldb','fax','whatsapp','getChannels','isValidChannel','toLowerCase','includes','clearBlockUser','isUndefined'];(function(_0x2dafbe,_0x5d04de){var _0x58a45a=function(_0x50ac96){while(--_0x50ac96){_0x2dafbe['push'](_0x2dafbe['shift']());}};_0x58a45a(++_0x5d04de);}(_0x48a0,0xdd));var _0x048a=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0x48a0[_0x122ef9];return _0x42fba0;};'use strict';var _=require(_0x048a('0x0'));var BPromise=require('bluebird');var db=require(_0x048a('0x1'))['db'];var util=require('./license/util');var channels=['voice','mail','chat',_0x048a('0x2'),'sms',_0x048a('0x3'),'openchannel'];exports[_0x048a('0x4')]=function(){return channels;};exports[_0x048a('0x5')]=function(_0x371f4e){_0x371f4e=_0x371f4e[_0x048a('0x6')]();return _[_0x048a('0x7')](channels,_0x371f4e);};exports[_0x048a('0x8')]=function(_0x2a68c3,_0x3bef6b,_0x26aa58,_0x4955ff){var _0x204351={'loginAttempts':_0x3bef6b,'blocked':_0x26aa58};if(!_[_0x048a('0x9')](_0x4955ff)){_0x204351[_0x048a('0xa')]=_0x4955ff;}return _0x2a68c3[_0x048a('0xb')](_0x204351);};exports['getLicense']=function(_0x3fcb5c){return new BPromise(function(_0x311ec9,_0x4412e7){var _0x38954c=0x0;if(_0x3fcb5c[_0x048a('0xc')]!==_0x048a('0xd')){_0x311ec9(_0x3fcb5c);}db[_0x048a('0xe')][_0x048a('0xf')]({'where':{'role':_0x048a('0xd'),'online':!![],'id':{'$ne':_0x3fcb5c['id']}}})[_0x048a('0x10')](function(_0x406bfc){_0x38954c=_0x406bfc;return util[_0x048a('0x11')]();})['then'](function(_0x246acf){if(_0x246acf&&_0x246acf[_0x048a('0x12')]&&_0x38954c>=_0x246acf[_0x048a('0x12')]){throw Error(_0x048a('0x13'));}_0x311ec9(_0x3fcb5c);})[_0x048a('0x14')](function(_0x46067a){_0x4412e7(_0x46067a);});});};