Built motion from commit d13fb11b.|2.6.34
[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 _0xf355=['catch','lodash','bluebird','../mysqldb','voice','mail','chat','fax','sms','getChannels','isValidChannel','includes','clearBlockUser','isUndefined','blockedAt','updateAttributes','getLicense','agent','User','count','then','Maximum\x20login\x20has\x20been\x20reached'];(function(_0x25efc3,_0x555aae){var _0x4d3891=function(_0x149c0a){while(--_0x149c0a){_0x25efc3['push'](_0x25efc3['shift']());}};_0x4d3891(++_0x555aae);}(_0xf355,0xc7));var _0x5f35=function(_0x43b9a6,_0x1c6137){_0x43b9a6=_0x43b9a6-0x0;var _0x447cd4=_0xf355[_0x43b9a6];return _0x447cd4;};'use strict';var _=require(_0x5f35('0x0'));var BPromise=require(_0x5f35('0x1'));var db=require(_0x5f35('0x2'))['db'];var util=require('./license/util');var channels=[_0x5f35('0x3'),_0x5f35('0x4'),_0x5f35('0x5'),_0x5f35('0x6'),_0x5f35('0x7'),'whatsapp','openchannel'];exports[_0x5f35('0x8')]=function(){return channels;};exports[_0x5f35('0x9')]=function(_0x31ccec){_0x31ccec=_0x31ccec['toLowerCase']();return _[_0x5f35('0xa')](channels,_0x31ccec);};exports[_0x5f35('0xb')]=function(_0x3c5b9c,_0x3cd84a,_0x2beb1b,_0x71f37a){var _0x93da03={'loginAttempts':_0x3cd84a,'blocked':_0x2beb1b};if(!_[_0x5f35('0xc')](_0x71f37a)){_0x93da03[_0x5f35('0xd')]=_0x71f37a;}return _0x3c5b9c[_0x5f35('0xe')](_0x93da03);};exports[_0x5f35('0xf')]=function(_0x18937b){return new BPromise(function(_0x1cfba2,_0x29db29){var _0x1df809=0x0;if(_0x18937b['role']!==_0x5f35('0x10')){_0x1cfba2(_0x18937b);}db[_0x5f35('0x11')][_0x5f35('0x12')]({'where':{'role':'agent','online':!![],'id':{'$ne':_0x18937b['id']}}})[_0x5f35('0x13')](function(_0x229cb3){_0x1df809=_0x229cb3;return util[_0x5f35('0xf')]();})['then'](function(_0x57a423){if(_0x57a423&&_0x57a423['agents']&&_0x1df809>=_0x57a423['agents']){throw Error(_0x5f35('0x14'));}_0x1cfba2(_0x18937b);})[_0x5f35('0x15')](function(_0x4cc167){_0x29db29(_0x4cc167);});});};