Built motion from commit 994c64e1.|2.6.1
[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 _0x25d6=['role','User','count','agent','then','getLicense','agents','lodash','bluebird','../mysqldb','./license/util','voice','mail','chat','whatsapp','getChannels','isValidChannel','toLowerCase','includes','clearBlockUser','blockedAt','updateAttributes'];(function(_0x481ffd,_0x29e90e){var _0x4242f0=function(_0x4a1038){while(--_0x4a1038){_0x481ffd['push'](_0x481ffd['shift']());}};_0x4242f0(++_0x29e90e);}(_0x25d6,0x8b));var _0x625d=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x25d6[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x625d('0x0'));var BPromise=require(_0x625d('0x1'));var db=require(_0x625d('0x2'))['db'];var util=require(_0x625d('0x3'));var channels=[_0x625d('0x4'),_0x625d('0x5'),_0x625d('0x6'),'fax','sms',_0x625d('0x7'),'openchannel'];exports[_0x625d('0x8')]=function(){return channels;};exports[_0x625d('0x9')]=function(_0x18902d){_0x18902d=_0x18902d[_0x625d('0xa')]();return _[_0x625d('0xb')](channels,_0x18902d);};exports[_0x625d('0xc')]=function(_0x37276f,_0x58125f,_0xe2905d,_0x430ef0){var _0x137ad4={'loginAttempts':_0x58125f,'blocked':_0xe2905d};if(!_['isUndefined'](_0x430ef0)){_0x137ad4[_0x625d('0xd')]=_0x430ef0;}return _0x37276f[_0x625d('0xe')](_0x137ad4);};exports['getLicense']=function(_0x19b6a6){return new BPromise(function(_0x458758,_0x41d8f4){var _0x1efae5=0x0;if(_0x19b6a6[_0x625d('0xf')]!=='agent'){_0x458758(_0x19b6a6);}db[_0x625d('0x10')][_0x625d('0x11')]({'where':{'role':_0x625d('0x12'),'online':!![],'id':{'$ne':_0x19b6a6['id']}}})[_0x625d('0x13')](function(_0xf76925){_0x1efae5=_0xf76925;return util[_0x625d('0x14')]();})[_0x625d('0x13')](function(_0x3a17b8){if(_0x3a17b8&&_0x3a17b8[_0x625d('0x15')]&&_0x1efae5>=_0x3a17b8[_0x625d('0x15')]){throw Error('Maximum\x20login\x20has\x20been\x20reached');}_0x458758(_0x19b6a6);})['catch'](function(_0x1fa6a4){_0x41d8f4(_0x1fa6a4);});});};