Built motion from commit 2b9af5da.|2.6.26
[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 _0xd014=['mail','chat','fax','openchannel','toLowerCase','includes','clearBlockUser','isUndefined','getLicense','role','count','agent','then','agents','Maximum\x20login\x20has\x20been\x20reached','lodash','../mysqldb','./license/util','voice'];(function(_0x18cd5b,_0x10240b){var _0x5eaa52=function(_0x2bccad){while(--_0x2bccad){_0x18cd5b['push'](_0x18cd5b['shift']());}};_0x5eaa52(++_0x10240b);}(_0xd014,0x1ea));var _0x4d01=function(_0x2170ed,_0xe46dbf){_0x2170ed=_0x2170ed-0x0;var _0x4dd2ca=_0xd014[_0x2170ed];return _0x4dd2ca;};'use strict';var _=require(_0x4d01('0x0'));var BPromise=require('bluebird');var db=require(_0x4d01('0x1'))['db'];var util=require(_0x4d01('0x2'));var channels=[_0x4d01('0x3'),_0x4d01('0x4'),_0x4d01('0x5'),_0x4d01('0x6'),'sms','whatsapp',_0x4d01('0x7')];exports['getChannels']=function(){return channels;};exports['isValidChannel']=function(_0x25c7b8){_0x25c7b8=_0x25c7b8[_0x4d01('0x8')]();return _[_0x4d01('0x9')](channels,_0x25c7b8);};exports[_0x4d01('0xa')]=function(_0x2a06fb,_0x5536d3,_0x4e7c3a,_0x2cec6b){var _0x5e3009={'loginAttempts':_0x5536d3,'blocked':_0x4e7c3a};if(!_[_0x4d01('0xb')](_0x2cec6b)){_0x5e3009['blockedAt']=_0x2cec6b;}return _0x2a06fb['updateAttributes'](_0x5e3009);};exports[_0x4d01('0xc')]=function(_0x5b9f07){return new BPromise(function(_0x4842df,_0x1652a4){var _0x1cb2a5=0x0;if(_0x5b9f07[_0x4d01('0xd')]!=='agent'){_0x4842df(_0x5b9f07);}db['User'][_0x4d01('0xe')]({'where':{'role':_0x4d01('0xf'),'online':!![],'id':{'$ne':_0x5b9f07['id']}}})[_0x4d01('0x10')](function(_0x22d1b2){_0x1cb2a5=_0x22d1b2;return util[_0x4d01('0xc')]();})[_0x4d01('0x10')](function(_0x2b14eb){if(_0x2b14eb&&_0x2b14eb[_0x4d01('0x11')]&&_0x1cb2a5>=_0x2b14eb['agents']){throw Error(_0x4d01('0x12'));}_0x4842df(_0x5b9f07);})['catch'](function(_0x4f8a01){_0x1652a4(_0x4f8a01);});});};