Built motion from commit 4fa9d4a7.|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 _0x2ded=['isValidChannel','toLowerCase','includes','isUndefined','blockedAt','updateAttributes','getLicense','role','agent','count','then','agents','bluebird','../mysqldb','./license/util','voice','chat','fax','sms','whatsapp','openchannel'];(function(_0x23dc88,_0x1e00db){var _0x4836e6=function(_0x21dc0b){while(--_0x21dc0b){_0x23dc88['push'](_0x23dc88['shift']());}};_0x4836e6(++_0x1e00db);}(_0x2ded,0xf3));var _0xd2de=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x2ded[_0x3dd15e];return _0x231fd0;};'use strict';var _=require('lodash');var BPromise=require(_0xd2de('0x0'));var db=require(_0xd2de('0x1'))['db'];var util=require(_0xd2de('0x2'));var channels=[_0xd2de('0x3'),'mail',_0xd2de('0x4'),_0xd2de('0x5'),_0xd2de('0x6'),_0xd2de('0x7'),_0xd2de('0x8')];exports['getChannels']=function(){return channels;};exports[_0xd2de('0x9')]=function(_0x2a8930){_0x2a8930=_0x2a8930[_0xd2de('0xa')]();return _[_0xd2de('0xb')](channels,_0x2a8930);};exports['clearBlockUser']=function(_0x4f2879,_0x448d84,_0x31f8d5,_0x3b3237){var _0x48b1c6={'loginAttempts':_0x448d84,'blocked':_0x31f8d5};if(!_[_0xd2de('0xc')](_0x3b3237)){_0x48b1c6[_0xd2de('0xd')]=_0x3b3237;}return _0x4f2879[_0xd2de('0xe')](_0x48b1c6);};exports[_0xd2de('0xf')]=function(_0x36b394){return new BPromise(function(_0xdfcd91,_0x4657f2){var _0x18ebfc=0x0;if(_0x36b394[_0xd2de('0x10')]!==_0xd2de('0x11')){_0xdfcd91(_0x36b394);}db['User'][_0xd2de('0x12')]({'where':{'role':'agent','online':!![],'id':{'$ne':_0x36b394['id']}}})[_0xd2de('0x13')](function(_0x35a033){_0x18ebfc=_0x35a033;return util[_0xd2de('0xf')]();})['then'](function(_0x5d3911){if(_0x5d3911&&_0x5d3911[_0xd2de('0x14')]&&_0x18ebfc>=_0x5d3911[_0xd2de('0x14')]){throw Error('Maximum\x20login\x20has\x20been\x20reached');}_0xdfcd91(_0x36b394);})['catch'](function(_0x26bfb8){_0x4657f2(_0x26bfb8);});});};