Built motion from commit 3c2ce842.|2.6.31
[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 _0x3e21=['count','then','agents','catch','bluebird','../mysqldb','./license/util','voice','chat','sms','whatsapp','openchannel','getChannels','isValidChannel','toLowerCase','blockedAt','updateAttributes','getLicense','role','agent','User'];(function(_0x24465c,_0x426147){var _0x2bcf6f=function(_0x56bdb8){while(--_0x56bdb8){_0x24465c['push'](_0x24465c['shift']());}};_0x2bcf6f(++_0x426147);}(_0x3e21,0x1d2));var _0x13e2=function(_0x173377,_0x3a940e){_0x173377=_0x173377-0x0;var _0xf46120=_0x3e21[_0x173377];return _0xf46120;};'use strict';var _=require('lodash');var BPromise=require(_0x13e2('0x0'));var db=require(_0x13e2('0x1'))['db'];var util=require(_0x13e2('0x2'));var channels=[_0x13e2('0x3'),'mail',_0x13e2('0x4'),'fax',_0x13e2('0x5'),_0x13e2('0x6'),_0x13e2('0x7')];exports[_0x13e2('0x8')]=function(){return channels;};exports[_0x13e2('0x9')]=function(_0x19ef20){_0x19ef20=_0x19ef20[_0x13e2('0xa')]();return _['includes'](channels,_0x19ef20);};exports['clearBlockUser']=function(_0x3517e9,_0x110ea9,_0x5b2d84,_0x25b59f){var _0x301563={'loginAttempts':_0x110ea9,'blocked':_0x5b2d84};if(!_['isUndefined'](_0x25b59f)){_0x301563[_0x13e2('0xb')]=_0x25b59f;}return _0x3517e9[_0x13e2('0xc')](_0x301563);};exports[_0x13e2('0xd')]=function(_0x5bfd11){return new BPromise(function(_0x53f470,_0x4cb452){var _0x4e581c=0x0;if(_0x5bfd11[_0x13e2('0xe')]!==_0x13e2('0xf')){_0x53f470(_0x5bfd11);}db[_0x13e2('0x10')][_0x13e2('0x11')]({'where':{'role':_0x13e2('0xf'),'online':!![],'id':{'$ne':_0x5bfd11['id']}}})[_0x13e2('0x12')](function(_0x50179e){_0x4e581c=_0x50179e;return util['getLicense']();})[_0x13e2('0x12')](function(_0x5003f0){if(_0x5003f0&&_0x5003f0[_0x13e2('0x13')]&&_0x4e581c>=_0x5003f0['agents']){throw Error('Maximum\x20login\x20has\x20been\x20reached');}_0x53f470(_0x5bfd11);})[_0x13e2('0x14')](function(_0x3959f7){_0x4cb452(_0x3959f7);});});};