Built motion from commit b5996064.|2.6.21
[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 _0x5f8e=['includes','clearBlockUser','blockedAt','getLicense','User','agent','then','agents','catch','lodash','bluebird','../mysqldb','voice','fax','sms','whatsapp','openchannel','getChannels','isValidChannel','toLowerCase'];(function(_0x4929fd,_0x2c9d98){var _0x1a700d=function(_0xf85861){while(--_0xf85861){_0x4929fd['push'](_0x4929fd['shift']());}};_0x1a700d(++_0x2c9d98);}(_0x5f8e,0xd1));var _0xe5f8=function(_0x45aa72,_0x8af642){_0x45aa72=_0x45aa72-0x0;var _0x75adaa=_0x5f8e[_0x45aa72];return _0x75adaa;};'use strict';var _=require(_0xe5f8('0x0'));var BPromise=require(_0xe5f8('0x1'));var db=require(_0xe5f8('0x2'))['db'];var util=require('./license/util');var channels=[_0xe5f8('0x3'),'mail','chat',_0xe5f8('0x4'),_0xe5f8('0x5'),_0xe5f8('0x6'),_0xe5f8('0x7')];exports[_0xe5f8('0x8')]=function(){return channels;};exports[_0xe5f8('0x9')]=function(_0xeddaf5){_0xeddaf5=_0xeddaf5[_0xe5f8('0xa')]();return _[_0xe5f8('0xb')](channels,_0xeddaf5);};exports[_0xe5f8('0xc')]=function(_0xa4ff91,_0x55e2f0,_0x309fb9,_0x4a4464){var _0x241420={'loginAttempts':_0x55e2f0,'blocked':_0x309fb9};if(!_['isUndefined'](_0x4a4464)){_0x241420[_0xe5f8('0xd')]=_0x4a4464;}return _0xa4ff91['updateAttributes'](_0x241420);};exports[_0xe5f8('0xe')]=function(_0x4ec143){return new BPromise(function(_0x47d949,_0x415e0a){var _0x6c0183=0x0;if(_0x4ec143['role']!=='agent'){_0x47d949(_0x4ec143);}db[_0xe5f8('0xf')]['count']({'where':{'role':_0xe5f8('0x10'),'online':!![],'id':{'$ne':_0x4ec143['id']}}})[_0xe5f8('0x11')](function(_0x3f8792){_0x6c0183=_0x3f8792;return util[_0xe5f8('0xe')]();})[_0xe5f8('0x11')](function(_0x4ce507){if(_0x4ce507&&_0x4ce507[_0xe5f8('0x12')]&&_0x6c0183>=_0x4ce507[_0xe5f8('0x12')]){throw Error('Maximum\x20login\x20has\x20been\x20reached');}_0x47d949(_0x4ec143);})[_0xe5f8('0x13')](function(_0x389fcc){_0x415e0a(_0x389fcc);});});};