Built motion from commit (unavailable).|2.5.14
[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 _0x3040=['sms','whatsapp','toLowerCase','clearBlockUser','isUndefined','blockedAt','updateAttributes','getLicense','User','count','agent','then','agents','Maximum\x20login\x20has\x20been\x20reached','catch','lodash','bluebird','../mysqldb','voice','fax'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x3040,0x87));var _0x0304=function(_0x3d4d41,_0x2ee486){_0x3d4d41=_0x3d4d41-0x0;var _0x20d879=_0x3040[_0x3d4d41];return _0x20d879;};'use strict';var _=require(_0x0304('0x0'));var BPromise=require(_0x0304('0x1'));var db=require(_0x0304('0x2'))['db'];var util=require('./license/util');var channels=[_0x0304('0x3'),'mail','chat',_0x0304('0x4'),_0x0304('0x5'),_0x0304('0x6'),'openchannel'];exports['getChannels']=function(){return channels;};exports['isValidChannel']=function(_0x5e78a2){_0x5e78a2=_0x5e78a2[_0x0304('0x7')]();return _['includes'](channels,_0x5e78a2);};exports[_0x0304('0x8')]=function(_0x448c72,_0x52b951,_0x4c82eb,_0x8376c9){var _0x5844bf={'loginAttempts':_0x52b951,'blocked':_0x4c82eb};if(!_[_0x0304('0x9')](_0x8376c9)){_0x5844bf[_0x0304('0xa')]=_0x8376c9;}return _0x448c72[_0x0304('0xb')](_0x5844bf);};exports[_0x0304('0xc')]=function(_0x1375ab){return new BPromise(function(_0x31276f,_0x272f1c){var _0x24f4eb=0x0;if(_0x1375ab['role']!=='agent'){_0x31276f(_0x1375ab);}db[_0x0304('0xd')][_0x0304('0xe')]({'where':{'role':_0x0304('0xf'),'online':!![],'id':{'$ne':_0x1375ab['id']}}})[_0x0304('0x10')](function(_0xfc4e67){_0x24f4eb=_0xfc4e67;return util[_0x0304('0xc')]();})[_0x0304('0x10')](function(_0x331d88){if(_0x331d88&&_0x331d88[_0x0304('0x11')]&&_0x24f4eb>=_0x331d88[_0x0304('0x11')]){throw Error(_0x0304('0x12'));}_0x31276f(_0x1375ab);})[_0x0304('0x13')](function(_0x36097c){_0x272f1c(_0x36097c);});});};