80c2364b0459ed4a8e162a3bbac634c443c4e84f
[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 _0x87db=['whatsapp','openchannel','getChannels','isValidChannel','toLowerCase','clearBlockUser','isUndefined','blockedAt','updateAttributes','role','agent','then','getLicense','agents','Maximum\x20login\x20has\x20been\x20reached','catch','lodash','../mysqldb','voice','mail','chat','sms'];(function(_0x1270b5,_0x1ad59a){var _0x2f4dfb=function(_0x4ed0e2){while(--_0x4ed0e2){_0x1270b5['push'](_0x1270b5['shift']());}};_0x2f4dfb(++_0x1ad59a);}(_0x87db,0xec));var _0xb87d=function(_0x61230a,_0x18a987){_0x61230a=_0x61230a-0x0;var _0x599813=_0x87db[_0x61230a];return _0x599813;};'use strict';var _=require(_0xb87d('0x0'));var BPromise=require('bluebird');var db=require(_0xb87d('0x1'))['db'];var util=require('./license/util');var channels=[_0xb87d('0x2'),_0xb87d('0x3'),_0xb87d('0x4'),'fax',_0xb87d('0x5'),_0xb87d('0x6'),_0xb87d('0x7')];exports[_0xb87d('0x8')]=function(){return channels;};exports[_0xb87d('0x9')]=function(_0x55a485){_0x55a485=_0x55a485[_0xb87d('0xa')]();return _['includes'](channels,_0x55a485);};exports[_0xb87d('0xb')]=function(_0x48a60d,_0x4ad412,_0x5904b9,_0x4ae538){var _0x5aa81a={'loginAttempts':_0x4ad412,'blocked':_0x5904b9};if(!_[_0xb87d('0xc')](_0x4ae538)){_0x5aa81a[_0xb87d('0xd')]=_0x4ae538;}return _0x48a60d[_0xb87d('0xe')](_0x5aa81a);};exports['getLicense']=function(_0x59bcd6){return new BPromise(function(_0x34309e,_0x18277e){var _0x33f221=0x0;if(_0x59bcd6[_0xb87d('0xf')]!==_0xb87d('0x10')){_0x34309e(_0x59bcd6);}db['User']['count']({'where':{'role':_0xb87d('0x10'),'online':!![],'id':{'$ne':_0x59bcd6['id']}}})[_0xb87d('0x11')](function(_0x4b5db4){_0x33f221=_0x4b5db4;return util[_0xb87d('0x12')]();})[_0xb87d('0x11')](function(_0x36d954){if(_0x36d954&&_0x36d954['agents']&&_0x33f221>=_0x36d954[_0xb87d('0x13')]){throw Error(_0xb87d('0x14'));}_0x34309e(_0x59bcd6);})[_0xb87d('0x15')](function(_0x518a55){_0x18277e(_0x518a55);});});};