b4d97ea6ca05427e421cb9e3269d7c7c9f0acae8
[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 _0x581a=['updateAttributes','getLicense','agent','then','agents','Maximum\x20login\x20has\x20been\x20reached','lodash','bluebird','../mysqldb','./license/util','fax','sms','whatsapp','isValidChannel','toLowerCase','includes','clearBlockUser','blockedAt'];(function(_0x47df54,_0x1aeb61){var _0x261b87=function(_0x54bc77){while(--_0x54bc77){_0x47df54['push'](_0x47df54['shift']());}};_0x261b87(++_0x1aeb61);}(_0x581a,0x14a));var _0xa581=function(_0x5b2e3c,_0x1008ec){_0x5b2e3c=_0x5b2e3c-0x0;var _0x181b20=_0x581a[_0x5b2e3c];return _0x181b20;};'use strict';var _=require(_0xa581('0x0'));var BPromise=require(_0xa581('0x1'));var db=require(_0xa581('0x2'))['db'];var util=require(_0xa581('0x3'));var channels=['voice','mail','chat',_0xa581('0x4'),_0xa581('0x5'),_0xa581('0x6'),'openchannel'];exports['getChannels']=function(){return channels;};exports[_0xa581('0x7')]=function(_0x8cab7d){_0x8cab7d=_0x8cab7d[_0xa581('0x8')]();return _[_0xa581('0x9')](channels,_0x8cab7d);};exports[_0xa581('0xa')]=function(_0x4cb99c,_0x398bc2,_0x3595f0,_0x4aef72){var _0x3e66e6={'loginAttempts':_0x398bc2,'blocked':_0x3595f0};if(!_['isUndefined'](_0x4aef72)){_0x3e66e6[_0xa581('0xb')]=_0x4aef72;}return _0x4cb99c[_0xa581('0xc')](_0x3e66e6);};exports[_0xa581('0xd')]=function(_0x44e658){return new BPromise(function(_0x2d1c73,_0x22d116){var _0x351058=0x0;if(_0x44e658['role']!==_0xa581('0xe')){_0x2d1c73(_0x44e658);}db['User']['count']({'where':{'role':_0xa581('0xe'),'online':!![],'id':{'$ne':_0x44e658['id']}}})[_0xa581('0xf')](function(_0x418844){_0x351058=_0x418844;return util['getLicense']();})[_0xa581('0xf')](function(_0x4d2608){if(_0x4d2608&&_0x4d2608[_0xa581('0x10')]&&_0x351058>=_0x4d2608[_0xa581('0x10')]){throw Error(_0xa581('0x11'));}_0x2d1c73(_0x44e658);})['catch'](function(_0x15fd3d){_0x22d116(_0x15fd3d);});});};