Built motion from commit 3c2ce842.|2.6.31
[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 _0x36e1=['updateAttributes','getLicense','agent','User','count','then','agents','Maximum\x20login\x20has\x20been\x20reached','bluebird','../mysqldb','voice','mail','chat','sms','openchannel','getChannels','isValidChannel','toLowerCase','clearBlockUser','isUndefined','blockedAt'];(function(_0x3ff517,_0x23a8d6){var _0x10337c=function(_0x410fb6){while(--_0x410fb6){_0x3ff517['push'](_0x3ff517['shift']());}};_0x10337c(++_0x23a8d6);}(_0x36e1,0xc5));var _0x136e=function(_0x4c184d,_0x4278ab){_0x4c184d=_0x4c184d-0x0;var _0x23d997=_0x36e1[_0x4c184d];return _0x23d997;};'use strict';var _=require('lodash');var BPromise=require(_0x136e('0x0'));var db=require(_0x136e('0x1'))['db'];var util=require('./license/util');var channels=[_0x136e('0x2'),_0x136e('0x3'),_0x136e('0x4'),'fax',_0x136e('0x5'),'whatsapp',_0x136e('0x6')];exports[_0x136e('0x7')]=function(){return channels;};exports[_0x136e('0x8')]=function(_0x55eee0){_0x55eee0=_0x55eee0[_0x136e('0x9')]();return _['includes'](channels,_0x55eee0);};exports[_0x136e('0xa')]=function(_0x48b343,_0x3ebdc2,_0x484083,_0xff484e){var _0x4dfab5={'loginAttempts':_0x3ebdc2,'blocked':_0x484083};if(!_[_0x136e('0xb')](_0xff484e)){_0x4dfab5[_0x136e('0xc')]=_0xff484e;}return _0x48b343[_0x136e('0xd')](_0x4dfab5);};exports[_0x136e('0xe')]=function(_0x49df48){return new BPromise(function(_0x103e17,_0x2e20e2){var _0x9026ae=0x0;if(_0x49df48['role']!==_0x136e('0xf')){_0x103e17(_0x49df48);}db[_0x136e('0x10')][_0x136e('0x11')]({'where':{'role':_0x136e('0xf'),'online':!![],'id':{'$ne':_0x49df48['id']}}})[_0x136e('0x12')](function(_0x22533c){_0x9026ae=_0x22533c;return util[_0x136e('0xe')]();})['then'](function(_0x21223e){if(_0x21223e&&_0x21223e[_0x136e('0x13')]&&_0x9026ae>=_0x21223e[_0x136e('0x13')]){throw Error(_0x136e('0x14'));}_0x103e17(_0x49df48);})['catch'](function(_0x1b7148){_0x2e20e2(_0x1b7148);});});};