30396fff2e0193552cc83ec298bd07ae660c8c7d
[motion2.git] / server / api / team / team.model.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 _0xb2b4=['exports','Team','Fax','Mail','Openchannel','Sms','Voice','Whatsapp','lodash','./team.attributes','get','Queues','then','map','catch'];(function(_0xa84f2,_0x2874de){var _0x1ae706=function(_0x50db96){while(--_0x50db96){_0xa84f2['push'](_0xa84f2['shift']());}};_0x1ae706(++_0x2874de);}(_0xb2b4,0xbc));var _0x4b2b=function(_0x4e0eb6,_0x240784){_0x4e0eb6=_0x4e0eb6-0x0;var _0x46e432=_0xb2b4[_0x4e0eb6];return _0x46e432;};'use strict';var _=require(_0x4b2b('0x0'));var attributes=require(_0x4b2b('0x1'));function getQueuesByChannel(_0x1ca645,_0x448df6){var _0x36df16=_0x4b2b('0x2')+_0x448df6+_0x4b2b('0x3');return _0x1ca645[_0x36df16]()[_0x4b2b('0x4')](function(_0x4ea346){return _[_0x4b2b('0x5')](_0x4ea346,function(_0x5953df){_0x5953df['setDataValue']('channel',_0x448df6);return _0x5953df;});})[_0x4b2b('0x6')](function(_0x4bae3c){throw _0x4bae3c;});}module[_0x4b2b('0x7')]=function(_0x12b20e){return _0x12b20e['define'](_0x4b2b('0x8'),attributes,{'tableName':'teams','paranoid':![],'indexes':[],'timestamps':!![],'instanceMethods':{'getAssociatedQueues':function(){var _0x457148=this;var _0x2ac3b7=['Chat',_0x4b2b('0x9'),_0x4b2b('0xa'),_0x4b2b('0xb'),_0x4b2b('0xc'),_0x4b2b('0xd'),_0x4b2b('0xe')];return Promise['resolve']()[_0x4b2b('0x4')](function(){var _0x46bcd7=_['map'](_0x2ac3b7,function(_0x1fe309){return getQueuesByChannel(_0x457148,_0x1fe309);});return Promise['all'](_0x46bcd7);})[_0x4b2b('0x6')](function(_0x8d1bc5){throw _0x8d1bc5;});}}});};