96a4291e06958233e1871f06edc7adc709f188a6
[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 _0x06ee=['fax','sms','openchannel','getChannels','isValidChannel','toLowerCase','clearBlockUser','isUndefined','blockedAt','getLicense','role','agent','count','then','agents','Maximum\x20login\x20has\x20been\x20reached','catch','lodash','../mysqldb','./license/util','voice','mail','chat'];(function(_0x2cfb58,_0x3d9412){var _0xd99951=function(_0x329afa){while(--_0x329afa){_0x2cfb58['push'](_0x2cfb58['shift']());}};_0xd99951(++_0x3d9412);}(_0x06ee,0x13c));var _0xe06e=function(_0x55b38b,_0x11dff0){_0x55b38b=_0x55b38b-0x0;var _0x53ec7a=_0x06ee[_0x55b38b];return _0x53ec7a;};'use strict';var _=require(_0xe06e('0x0'));var BPromise=require('bluebird');var db=require(_0xe06e('0x1'))['db'];var util=require(_0xe06e('0x2'));var channels=[_0xe06e('0x3'),_0xe06e('0x4'),_0xe06e('0x5'),_0xe06e('0x6'),_0xe06e('0x7'),'whatsapp',_0xe06e('0x8')];exports[_0xe06e('0x9')]=function(){return channels;};exports[_0xe06e('0xa')]=function(_0x1c1bd8){_0x1c1bd8=_0x1c1bd8[_0xe06e('0xb')]();return _['includes'](channels,_0x1c1bd8);};exports[_0xe06e('0xc')]=function(_0x20b8cc,_0x497ab2,_0x520c1a,_0x433c7e){var _0x327a96={'loginAttempts':_0x497ab2,'blocked':_0x520c1a};if(!_[_0xe06e('0xd')](_0x433c7e)){_0x327a96[_0xe06e('0xe')]=_0x433c7e;}return _0x20b8cc['updateAttributes'](_0x327a96);};exports[_0xe06e('0xf')]=function(_0x510520){return new BPromise(function(_0x484257,_0x2eac80){var _0x103b62=0x0;if(_0x510520[_0xe06e('0x10')]!==_0xe06e('0x11')){_0x484257(_0x510520);}db['User'][_0xe06e('0x12')]({'where':{'role':'agent','online':!![],'id':{'$ne':_0x510520['id']}}})['then'](function(_0x16ccca){_0x103b62=_0x16ccca;return util[_0xe06e('0xf')]();})[_0xe06e('0x13')](function(_0x36eb19){if(_0x36eb19&&_0x36eb19[_0xe06e('0x14')]&&_0x103b62>=_0x36eb19['agents']){throw Error(_0xe06e('0x15'));}_0x484257(_0x510520);})[_0xe06e('0x16')](function(_0x4f1a31){_0x2eac80(_0x4f1a31);});});};