Built motion from commit 9e1399f3.|2.5.37
[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 _0xc857=['chat','fax','sms','whatsapp','getChannels','isValidChannel','toLowerCase','isUndefined','blockedAt','updateAttributes','getLicense','role','agent','User','then','agents','catch','../mysqldb','./license/util','voice','mail'];(function(_0x3d9dc2,_0x57a41f){var _0x3392e5=function(_0x41c88e){while(--_0x41c88e){_0x3d9dc2['push'](_0x3d9dc2['shift']());}};_0x3392e5(++_0x57a41f);}(_0xc857,0x1f4));var _0x7c85=function(_0xc63824,_0x3908bc){_0xc63824=_0xc63824-0x0;var _0x493a33=_0xc857[_0xc63824];return _0x493a33;};'use strict';var _=require('lodash');var BPromise=require('bluebird');var db=require(_0x7c85('0x0'))['db'];var util=require(_0x7c85('0x1'));var channels=[_0x7c85('0x2'),_0x7c85('0x3'),_0x7c85('0x4'),_0x7c85('0x5'),_0x7c85('0x6'),_0x7c85('0x7'),'openchannel'];exports[_0x7c85('0x8')]=function(){return channels;};exports[_0x7c85('0x9')]=function(_0x138496){_0x138496=_0x138496[_0x7c85('0xa')]();return _['includes'](channels,_0x138496);};exports['clearBlockUser']=function(_0xa7db8,_0x4d3021,_0x4deb2f,_0x4ccbce){var _0x48ebc9={'loginAttempts':_0x4d3021,'blocked':_0x4deb2f};if(!_[_0x7c85('0xb')](_0x4ccbce)){_0x48ebc9[_0x7c85('0xc')]=_0x4ccbce;}return _0xa7db8[_0x7c85('0xd')](_0x48ebc9);};exports[_0x7c85('0xe')]=function(_0x169624){return new BPromise(function(_0x33ce8c,_0x54f919){var _0x1150b5=0x0;if(_0x169624[_0x7c85('0xf')]!==_0x7c85('0x10')){_0x33ce8c(_0x169624);}db[_0x7c85('0x11')]['count']({'where':{'role':_0x7c85('0x10'),'online':!![],'id':{'$ne':_0x169624['id']}}})[_0x7c85('0x12')](function(_0x4c9b48){_0x1150b5=_0x4c9b48;return util['getLicense']();})[_0x7c85('0x12')](function(_0xbc8f89){if(_0xbc8f89&&_0xbc8f89[_0x7c85('0x13')]&&_0x1150b5>=_0xbc8f89[_0x7c85('0x13')]){throw Error('Maximum\x20login\x20has\x20been\x20reached');}_0x33ce8c(_0x169624);})[_0x7c85('0x14')](function(_0x5b6371){_0x54f919(_0x5b6371);});});};