5b2fac55772aa1cc83a7bfee391910496724d067
[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 _0x8ee5=['getLicense','role','agent','User','count','then','Maximum\x20login\x20has\x20been\x20reached','catch','lodash','bluebird','../mysqldb','./license/util','mail','whatsapp','openchannel','getChannels','toLowerCase','includes','clearBlockUser','blockedAt','updateAttributes'];(function(_0x50c537,_0x5401fb){var _0x546147=function(_0x184cae){while(--_0x184cae){_0x50c537['push'](_0x50c537['shift']());}};_0x546147(++_0x5401fb);}(_0x8ee5,0x182));var _0x58ee=function(_0x2e52e0,_0x2fcaf2){_0x2e52e0=_0x2e52e0-0x0;var _0xb4b909=_0x8ee5[_0x2e52e0];return _0xb4b909;};'use strict';var _=require(_0x58ee('0x0'));var BPromise=require(_0x58ee('0x1'));var db=require(_0x58ee('0x2'))['db'];var util=require(_0x58ee('0x3'));var channels=['voice',_0x58ee('0x4'),'chat','fax','sms',_0x58ee('0x5'),_0x58ee('0x6')];exports[_0x58ee('0x7')]=function(){return channels;};exports['isValidChannel']=function(_0x34c827){_0x34c827=_0x34c827[_0x58ee('0x8')]();return _[_0x58ee('0x9')](channels,_0x34c827);};exports[_0x58ee('0xa')]=function(_0x20004f,_0x56b27e,_0x55447f,_0x1ea974){var _0x4f6657={'loginAttempts':_0x56b27e,'blocked':_0x55447f};if(!_['isUndefined'](_0x1ea974)){_0x4f6657[_0x58ee('0xb')]=_0x1ea974;}return _0x20004f[_0x58ee('0xc')](_0x4f6657);};exports[_0x58ee('0xd')]=function(_0x2427ac){return new BPromise(function(_0x4e7fed,_0x2f311d){var _0x4ef43b=0x0;if(_0x2427ac[_0x58ee('0xe')]!==_0x58ee('0xf')){_0x4e7fed(_0x2427ac);}db[_0x58ee('0x10')][_0x58ee('0x11')]({'where':{'role':'agent','online':!![],'id':{'$ne':_0x2427ac['id']}}})['then'](function(_0x1cc553){_0x4ef43b=_0x1cc553;return util['getLicense']();})[_0x58ee('0x12')](function(_0x5bf39c){if(_0x5bf39c&&_0x5bf39c['agents']&&_0x4ef43b>=_0x5bf39c['agents']){throw Error(_0x58ee('0x13'));}_0x4e7fed(_0x2427ac);})[_0x58ee('0x14')](function(_0x13e0ab){_0x2f311d(_0x13e0ab);});});};