Built motion from commit d1eab355.|2.6.28
[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 _0x6cea=['updateAttributes','getLicense','role','agent','User','count','then','agents','Maximum\x20login\x20has\x20been\x20reached','bluebird','../mysqldb','./license/util','voice','chat','sms','whatsapp','openchannel','getChannels','toLowerCase','includes','blockedAt'];(function(_0x51e367,_0x2cc73c){var _0x4ab728=function(_0x327807){while(--_0x327807){_0x51e367['push'](_0x51e367['shift']());}};_0x4ab728(++_0x2cc73c);}(_0x6cea,0x9c));var _0xa6ce=function(_0x4253cb,_0x238ebc){_0x4253cb=_0x4253cb-0x0;var _0x5433dc=_0x6cea[_0x4253cb];return _0x5433dc;};'use strict';var _=require('lodash');var BPromise=require(_0xa6ce('0x0'));var db=require(_0xa6ce('0x1'))['db'];var util=require(_0xa6ce('0x2'));var channels=[_0xa6ce('0x3'),'mail',_0xa6ce('0x4'),'fax',_0xa6ce('0x5'),_0xa6ce('0x6'),_0xa6ce('0x7')];exports[_0xa6ce('0x8')]=function(){return channels;};exports['isValidChannel']=function(_0x2322ce){_0x2322ce=_0x2322ce[_0xa6ce('0x9')]();return _[_0xa6ce('0xa')](channels,_0x2322ce);};exports['clearBlockUser']=function(_0xcbd73c,_0x50be63,_0x435ed2,_0x29ebcf){var _0x3014fa={'loginAttempts':_0x50be63,'blocked':_0x435ed2};if(!_['isUndefined'](_0x29ebcf)){_0x3014fa[_0xa6ce('0xb')]=_0x29ebcf;}return _0xcbd73c[_0xa6ce('0xc')](_0x3014fa);};exports[_0xa6ce('0xd')]=function(_0x3b5b0a){return new BPromise(function(_0x2a82b6,_0xd20e3e){var _0x3cb043=0x0;if(_0x3b5b0a[_0xa6ce('0xe')]!==_0xa6ce('0xf')){_0x2a82b6(_0x3b5b0a);}db[_0xa6ce('0x10')][_0xa6ce('0x11')]({'where':{'role':'agent','online':!![],'id':{'$ne':_0x3b5b0a['id']}}})[_0xa6ce('0x12')](function(_0x189d3c){_0x3cb043=_0x189d3c;return util[_0xa6ce('0xd')]();})[_0xa6ce('0x12')](function(_0x11b130){if(_0x11b130&&_0x11b130[_0xa6ce('0x13')]&&_0x3cb043>=_0x11b130['agents']){throw Error(_0xa6ce('0x14'));}_0x2a82b6(_0x3b5b0a);})['catch'](function(_0x473b26){_0xd20e3e(_0x473b26);});});};