aeaeaf399c02a7c6ca6484494f53c34cf094e842
[motion2.git] / server / components / interaction / service.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 _0xea61=['contactName','closed','getClosedOrderClause','DESC','getFilteredInteractions','catch','tracked','query','clone','body','html','phone','fax','mobile','lodash','./sql-utils','./utils','findAll','skipInteractionsQuery','getInteractionsQuery','resolve','search','parseAdvancedSearchFilter','where','contact','default','fields','filter','user','having','read','then','group','ids','tag','countFilteredInteractions','length','count','clause','order'];(function(_0x1fd8b3,_0x3bd29a){var _0x1f461f=function(_0x171f72){while(--_0x171f72){_0x1fd8b3['push'](_0x1fd8b3['shift']());}};_0x1f461f(++_0x3bd29a);}(_0xea61,0xfe));var _0x1ea6=function(_0x41091c,_0x5d2743){_0x41091c=_0x41091c-0x0;var _0x208f19=_0xea61[_0x41091c];return _0x208f19;};'use strict';var _=require(_0x1ea6('0x0'));var sqlUtils=require(_0x1ea6('0x1'));var utils=require(_0x1ea6('0x2'));exports[_0x1ea6('0x3')]=function(_0x5c21a3,_0x22c6bf,_0x142ab1,_0x3bbe02,_0x1aa875){var _0x13eccd={'count':0x0,'rows':[]};var _0x1e37b2=sqlUtils[_0x1ea6('0x4')](_0x5c21a3,_0x142ab1,_0x22c6bf);if(_0x1e37b2){return Promise['resolve'](_0x13eccd);}var _0x389957=sqlUtils[_0x1ea6('0x5')](_0x5c21a3);var _0x1a92b3={};return Promise[_0x1ea6('0x6')]()['then'](function(){if(_0x22c6bf[_0x1ea6('0x7')]){return sqlUtils[_0x1ea6('0x8')](_0x22c6bf[_0x1ea6('0x7')],_0x1aa875);}else{return sqlUtils['parseQueryParameters'](_0x5c21a3,_0x22c6bf,_0x1aa875);}})['then'](function(_0x302e09){_0x389957[_0x1ea6('0x9')](_0x302e09['body']);_0x389957[_0x1ea6('0x9')](_0x302e09[_0x1ea6('0xa')]);_0x389957[_0x1ea6('0x9')](_0x302e09[_0x1ea6('0xb')]);_0x389957[_0x1ea6('0x9')](_0x302e09[_0x1ea6('0xc')]);_0x389957['where'](_0x302e09[_0x1ea6('0xd')]);_0x389957[_0x1ea6('0x9')](_0x302e09[_0x1ea6('0xe')]);_0x389957[_0x1ea6('0xf')](_0x302e09[_0x1ea6('0x10')]);_0x1a92b3=_0x302e09['tags'];return sqlUtils['checkAccountsRestrictions'](_0x5c21a3,_0x142ab1,_0x22c6bf);})[_0x1ea6('0x11')](function(_0x14c7ab){_0x389957['where'](_0x14c7ab);_0x389957[_0x1ea6('0x12')]('i.id');var _0x228ef8=_0x22c6bf[_0x1ea6('0x7')]?_0x1a92b3[_0x1ea6('0x13')]:_0x22c6bf[_0x1ea6('0x14')];return sqlUtils[_0x1ea6('0x15')](_0x389957,_0x228ef8);})[_0x1ea6('0x11')](function(_0x437088){_0x13eccd['count']=_0x437088[_0x1ea6('0x16')];if(_0x13eccd[_0x1ea6('0x17')]===0x0){return[];}_0x389957['having'](_0x1a92b3[_0x1ea6('0x18')]);if(_0x3bbe02[_0x1ea6('0x19')]){_0x3bbe02[_0x1ea6('0x19')]['forEach'](function(_0x2f55ef){var _0x1047c2=_0x2f55ef[0x0]===_0x1ea6('0x1a')?_0x2f55ef[0x0]:'i.'+_0x2f55ef[0x0];_0x389957[_0x1ea6('0x19')](_0x1047c2,_0x2f55ef[0x1]==='DESC'?![]:!![]);if(_0x2f55ef[0x0]===_0x1ea6('0x1b')){var _0x16eda0=sqlUtils[_0x1ea6('0x1c')](_0x5c21a3,_0x22c6bf);_0x389957['order'](_0x16eda0,_0x2f55ef[0x1]===_0x1ea6('0x1d')?![]:!![]);}});}return sqlUtils[_0x1ea6('0x1e')](_0x5c21a3,_0x389957,_0x22c6bf,_0x3bbe02);})[_0x1ea6('0x11')](function(_0x4c6523){_0x13eccd['rows']=_0x4c6523;return _0x13eccd;})[_0x1ea6('0x1f')](function(_0x1dc452){throw _0x1dc452;});};exports[_0x1ea6('0x20')]=function(_0x11b473,_0x222186){return function(_0x9e0269,_0x18bee9,_0x32c43d){var _0x34e40=_0x9e0269['user'];var _0x413c5e={};var _0x159eee=_0x9e0269[_0x1ea6('0x21')];if(_0x413c5e){_0x413c5e=_[_0x1ea6('0x22')](_0x9e0269['body']);_0x413c5e=_['omit'](_0x413c5e,[_0x1ea6('0x23'),_0x1ea6('0x24'),_0x1ea6('0x25'),_0x1ea6('0x26'),_0x1ea6('0x27')]);}utils['updateUser'](_0x34e40,_0x413c5e,_0x159eee,_0x11b473,_0x222186);_0x32c43d(null);};};