Built motion from commit 25580385.|2.6.2
[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 _0x99cd=['whatsapp','openchannel','isValidChannel','toLowerCase','blockedAt','updateAttributes','getLicense','role','count','agent','then','agents','Maximum\x20login\x20has\x20been\x20reached','catch','lodash','bluebird','../mysqldb','voice','mail','fax'];(function(_0xbf171b,_0x21c916){var _0x21ab7e=function(_0x46a03d){while(--_0x46a03d){_0xbf171b['push'](_0xbf171b['shift']());}};_0x21ab7e(++_0x21c916);}(_0x99cd,0x9a));var _0xd99c=function(_0x166b35,_0x3ad006){_0x166b35=_0x166b35-0x0;var _0x5b1cae=_0x99cd[_0x166b35];return _0x5b1cae;};'use strict';var _=require(_0xd99c('0x0'));var BPromise=require(_0xd99c('0x1'));var db=require(_0xd99c('0x2'))['db'];var util=require('./license/util');var channels=[_0xd99c('0x3'),_0xd99c('0x4'),'chat',_0xd99c('0x5'),'sms',_0xd99c('0x6'),_0xd99c('0x7')];exports['getChannels']=function(){return channels;};exports[_0xd99c('0x8')]=function(_0x413416){_0x413416=_0x413416[_0xd99c('0x9')]();return _['includes'](channels,_0x413416);};exports['clearBlockUser']=function(_0xd4bb24,_0x281bfd,_0x58a8a1,_0x629bc6){var _0x9120d={'loginAttempts':_0x281bfd,'blocked':_0x58a8a1};if(!_['isUndefined'](_0x629bc6)){_0x9120d[_0xd99c('0xa')]=_0x629bc6;}return _0xd4bb24[_0xd99c('0xb')](_0x9120d);};exports[_0xd99c('0xc')]=function(_0x3f9af3){return new BPromise(function(_0x1d31c9,_0x5bc5b5){var _0x1199c8=0x0;if(_0x3f9af3[_0xd99c('0xd')]!=='agent'){_0x1d31c9(_0x3f9af3);}db['User'][_0xd99c('0xe')]({'where':{'role':_0xd99c('0xf'),'online':!![],'id':{'$ne':_0x3f9af3['id']}}})[_0xd99c('0x10')](function(_0x397cc0){_0x1199c8=_0x397cc0;return util['getLicense']();})[_0xd99c('0x10')](function(_0x574395){if(_0x574395&&_0x574395[_0xd99c('0x11')]&&_0x1199c8>=_0x574395['agents']){throw Error(_0xd99c('0x12'));}_0x1d31c9(_0x3f9af3);})[_0xd99c('0x13')](function(_0x145f94){_0x5bc5b5(_0x145f94);});});};