Built motion from commit 8271bb6f.|2.6.28
[motion2.git] / server / components / contacts / index.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 _0x957f=['countFilteredContacts','count','User','buildContactsQuery','clause','getFilteredContacts','rows','catch','describe','CmContact','keys','cf_','map','CmCustomField','findOne','all','length','fieldType','type','lodash','./sql-utils','skipContactsQuery','resolve','getContactsSubquery','then','parseAdvancedSearchFilter','search','where','default','fields','filter','user','tags','skip','ids','tag'];(function(_0x999b85,_0x1edc2b){var _0x1d7124=function(_0x59cd29){while(--_0x59cd29){_0x999b85['push'](_0x999b85['shift']());}};_0x1d7124(++_0x1edc2b);}(_0x957f,0x10f));var _0xf957=function(_0x179b74,_0x5dc97d){_0x179b74=_0x179b74-0x0;var _0x268f76=_0x957f[_0x179b74];return _0x268f76;};'use strict';var _=require(_0xf957('0x0'));var sqlUtils=require(_0xf957('0x1'));var db=require('../../mysqldb')['db'];exports['findAll']=function(_0x488023,_0x225d9d,_0x48c2da,_0x67d867){var _0x4abc38={'count':0x0,'rows':[]};var _0x4027ef=sqlUtils[_0xf957('0x2')](_0x225d9d,_0x488023);if(_0x4027ef){return Promise[_0xf957('0x3')](_0x4abc38);}var _0x16e34b=sqlUtils[_0xf957('0x4')]();var _0x59a734={};var _0x48cf3c=![];var _0x3145d9=![];return Promise[_0xf957('0x3')]()[_0xf957('0x5')](function(){if(_0x488023['search']){return sqlUtils[_0xf957('0x6')](_0x488023[_0xf957('0x7')],_0x67d867);}else{return sqlUtils['parseQueryParameters'](_0x488023,_0x67d867);}})['then'](function(_0x162ed6){_0x16e34b[_0xf957('0x8')](_0x162ed6[_0xf957('0x9')]);_0x16e34b[_0xf957('0x8')](_0x162ed6[_0xf957('0xa')]);_0x16e34b[_0xf957('0x8')](_0x162ed6[_0xf957('0xb')]);_0x16e34b['where'](_0x162ed6[_0xf957('0xc')]['clause']);_0x59a734=_0x162ed6[_0xf957('0xd')];_0x3145d9=_0x162ed6[_0xf957('0xc')][_0xf957('0xe')];return sqlUtils['checkListsRestrictions'](_0x225d9d,_0x488023,_0x3145d9);})[_0xf957('0x5')](function(_0x4f199b){_0x16e34b[_0xf957('0x8')](_0x4f199b);var _0x4067ae=_0x488023[_0xf957('0x7')]?_0x59a734[_0xf957('0xf')]:_0x488023[_0xf957('0x10')];_0x48cf3c=_0x4067ae?!![]:![];return sqlUtils[_0xf957('0x11')](_0x16e34b,_0x4067ae);})[_0xf957('0x5')](function(_0x301824){_0x4abc38[_0xf957('0x12')]=_0x301824;if(_0x4abc38[_0xf957('0x12')]===0x0){return;}if(_0x488023[_0xf957('0x13')]){_0x3145d9=!![];}return sqlUtils[_0xf957('0x14')](_0x16e34b,_0x488023[_0xf957('0xa')],_0x48c2da,_0x48cf3c,_0x59a734[_0xf957('0x15')],_0x3145d9);})[_0xf957('0x5')](function(_0x3fc914){if(!_0x3fc914){return[];}return sqlUtils[_0xf957('0x16')](_0x3fc914,_0x488023,_0x48c2da);})[_0xf957('0x5')](function(_0x30feff){_0x4abc38[_0xf957('0x17')]=_0x30feff;return _0x4abc38;})[_0xf957('0x18')](function(_0x4b74a8){throw _0x4b74a8;});};exports[_0xf957('0x19')]=function(){var _0x409516={};var _0x441c65=[];return db[_0xf957('0x1a')][_0xf957('0x19')]()[_0xf957('0x5')](function(_0x1e739b){_0x409516=_0x1e739b;var _0x1c0fb5=Object[_0xf957('0x1b')](_0x409516)[_0xf957('0xb')](function(_0xb86df6){return _['startsWith'](_0xb86df6,_0xf957('0x1c'))?_0xb86df6:undefined;});var _0x39631a=_0x1c0fb5[_0xf957('0x1d')](function(_0x5b9e4d){return db[_0xf957('0x1e')][_0xf957('0x1f')]({'where':{'id':_0x5b9e4d['slice'](0x3)},'raw':!![]});});return Promise[_0xf957('0x20')](_0x39631a);})[_0xf957('0x5')](function(_0x315db0){for(var _0x3db9c4=0x0;_0x3db9c4<_0x315db0[_0xf957('0x21')];_0x3db9c4++){if(_0x315db0[_0x3db9c4]){var _0x13ab6f=_0xf957('0x1c')+_0x315db0[_0x3db9c4]['id'];_0x409516[_0x13ab6f][_0xf957('0x22')]=_0x315db0[_0x3db9c4]['type'];}}_0x441c65=_[_0xf957('0x1d')](Object[_0xf957('0x1b')](_0x409516),function(_0x3e4eaf){return{'name':_0x3e4eaf,'type':_0x409516[_0x3e4eaf][_0xf957('0x23')]};});return _0x441c65;})[_0xf957('0x18')](function(_0x4cca20){throw _0x4cca20;});};