8a5ffaeba04a079d1e3f8885827bdc76718ac2be
[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 _0xfe7b=['clause','order','forEach','contactName','closed','DESC','getFilteredInteractions','rows','catch','query','omit','phone','fax','mobile','updateUser','lodash','./utils','skipInteractionsQuery','resolve','getInteractionsQuery','then','search','parseQueryParameters','body','where','contact','default','fields','filter','user','having','read','tags','checkAccountsRestrictions','group','i.id','tag','countFilteredInteractions','count'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0xfe7b,0xf9));var _0xbfe7=function(_0x4e2148,_0x382a2c){_0x4e2148=_0x4e2148-0x0;var _0x323345=_0xfe7b[_0x4e2148];return _0x323345;};'use strict';var _=require(_0xbfe7('0x0'));var sqlUtils=require('./sql-utils');var utils=require(_0xbfe7('0x1'));exports['findAll']=function(_0x4e5f20,_0x180a66,_0x5ebc48,_0x4f08b9,_0x388350){var _0x5a7d85={'count':0x0,'rows':[]};var _0x2cc2b3=sqlUtils[_0xbfe7('0x2')](_0x4e5f20,_0x5ebc48,_0x180a66);if(_0x2cc2b3){return Promise[_0xbfe7('0x3')](_0x5a7d85);}var _0x311a1c=sqlUtils[_0xbfe7('0x4')](_0x4e5f20);var _0x15e72d={};return Promise[_0xbfe7('0x3')]()[_0xbfe7('0x5')](function(){if(_0x180a66[_0xbfe7('0x6')]){return sqlUtils['parseAdvancedSearchFilter'](_0x180a66['search'],_0x388350);}else{return sqlUtils[_0xbfe7('0x7')](_0x4e5f20,_0x180a66,_0x388350);}})[_0xbfe7('0x5')](function(_0x30b0ac){_0x311a1c['where'](_0x30b0ac[_0xbfe7('0x8')]);_0x311a1c[_0xbfe7('0x9')](_0x30b0ac[_0xbfe7('0xa')]);_0x311a1c[_0xbfe7('0x9')](_0x30b0ac[_0xbfe7('0xb')]);_0x311a1c['where'](_0x30b0ac[_0xbfe7('0xc')]);_0x311a1c[_0xbfe7('0x9')](_0x30b0ac[_0xbfe7('0xd')]);_0x311a1c[_0xbfe7('0x9')](_0x30b0ac[_0xbfe7('0xe')]);_0x311a1c[_0xbfe7('0xf')](_0x30b0ac[_0xbfe7('0x10')]);_0x15e72d=_0x30b0ac[_0xbfe7('0x11')];return sqlUtils[_0xbfe7('0x12')](_0x4e5f20,_0x5ebc48,_0x180a66);})[_0xbfe7('0x5')](function(_0x13515c){_0x311a1c[_0xbfe7('0x9')](_0x13515c);_0x311a1c[_0xbfe7('0x13')](_0xbfe7('0x14'));var _0x143043=_0x180a66[_0xbfe7('0x6')]?_0x15e72d['ids']:_0x180a66[_0xbfe7('0x15')];return sqlUtils[_0xbfe7('0x16')](_0x311a1c,_0x143043);})['then'](function(_0x5c45ed){_0x5a7d85[_0xbfe7('0x17')]=_0x5c45ed['length'];if(_0x5a7d85[_0xbfe7('0x17')]===0x0){return[];}_0x311a1c[_0xbfe7('0xf')](_0x15e72d[_0xbfe7('0x18')]);if(_0x4f08b9['order']){_0x4f08b9[_0xbfe7('0x19')][_0xbfe7('0x1a')](function(_0x33709a){var _0xe7f737=_0x33709a[0x0]===_0xbfe7('0x1b')?_0x33709a[0x0]:'i.'+_0x33709a[0x0];_0x311a1c[_0xbfe7('0x19')](_0xe7f737,_0x33709a[0x1]==='DESC'?![]:!![]);if(_0x33709a[0x0]===_0xbfe7('0x1c')){var _0x25e877=sqlUtils['getClosedOrderClause'](_0x4e5f20,_0x180a66);_0x311a1c['order'](_0x25e877,_0x33709a[0x1]===_0xbfe7('0x1d')?![]:!![]);}});}return sqlUtils[_0xbfe7('0x1e')](_0x4e5f20,_0x311a1c,_0x180a66,_0x4f08b9);})['then'](function(_0x22891d){_0x5a7d85[_0xbfe7('0x1f')]=_0x22891d;return _0x5a7d85;})[_0xbfe7('0x20')](function(_0x403c49){throw _0x403c49;});};exports['tracked']=function(_0x1046a0,_0x4c7586){return function(_0x5b0857,_0x2fae19,_0xf10dd2){var _0x191ee5=_0x5b0857[_0xbfe7('0xe')];var _0x1f3479={};var _0x19487e=_0x5b0857[_0xbfe7('0x21')];if(_0x1f3479){_0x1f3479=_['clone'](_0x5b0857['body']);_0x1f3479=_[_0xbfe7('0x22')](_0x1f3479,[_0xbfe7('0x8'),'html',_0xbfe7('0x23'),_0xbfe7('0x24'),_0xbfe7('0x25')]);}utils[_0xbfe7('0x26')](_0x191ee5,_0x1f3479,_0x19487e,_0x1046a0,_0x4c7586);_0xf10dd2(null);};};