00ceb45e9b8591d13e2d5df8089cbef22408c616
[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 _0xe95f=['openchannel','getChannels','isValidChannel','toLowerCase','includes','clearBlockUser','isUndefined','blockedAt','getLicense','agent','User','count','then','agents','lodash','../mysqldb','./license/util','voice','mail','chat','fax','sms','whatsapp'];(function(_0xe7c5b7,_0x27691d){var _0x1a1b70=function(_0xdb334){while(--_0xdb334){_0xe7c5b7['push'](_0xe7c5b7['shift']());}};_0x1a1b70(++_0x27691d);}(_0xe95f,0x139));var _0xfe95=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xe95f[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0xfe95('0x0'));var BPromise=require('bluebird');var db=require(_0xfe95('0x1'))['db'];var util=require(_0xfe95('0x2'));var channels=[_0xfe95('0x3'),_0xfe95('0x4'),_0xfe95('0x5'),_0xfe95('0x6'),_0xfe95('0x7'),_0xfe95('0x8'),_0xfe95('0x9')];exports[_0xfe95('0xa')]=function(){return channels;};exports[_0xfe95('0xb')]=function(_0x25cecf){_0x25cecf=_0x25cecf[_0xfe95('0xc')]();return _[_0xfe95('0xd')](channels,_0x25cecf);};exports[_0xfe95('0xe')]=function(_0x21328f,_0x3aa580,_0xf5ae70,_0x340957){var _0x16c729={'loginAttempts':_0x3aa580,'blocked':_0xf5ae70};if(!_[_0xfe95('0xf')](_0x340957)){_0x16c729[_0xfe95('0x10')]=_0x340957;}return _0x21328f['updateAttributes'](_0x16c729);};exports[_0xfe95('0x11')]=function(_0x2b53fa){return new BPromise(function(_0x361091,_0x20ad63){var _0x21124c=0x0;if(_0x2b53fa['role']!==_0xfe95('0x12')){_0x361091(_0x2b53fa);}db[_0xfe95('0x13')][_0xfe95('0x14')]({'where':{'role':_0xfe95('0x12'),'online':!![],'id':{'$ne':_0x2b53fa['id']}}})[_0xfe95('0x15')](function(_0x175668){_0x21124c=_0x175668;return util[_0xfe95('0x11')]();})[_0xfe95('0x15')](function(_0x3fd543){if(_0x3fd543&&_0x3fd543['agents']&&_0x21124c>=_0x3fd543[_0xfe95('0x16')]){throw Error('Maximum\x20login\x20has\x20been\x20reached');}_0x361091(_0x2b53fa);})['catch'](function(_0x70343d){_0x20ad63(_0x70343d);});});};