Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / api / userProfileSection / userProfileSection.controller.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 _0xeb38=['api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','end','status','count','offset','limit','set','Content-Range','json','apply','reject','save','update','then','destroy','stack','name','send','index','map','UserProfileSection','rawAttributes','fieldName','type','key','model','query','keys','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','where','filters','merge','VIRTUAL','includeAll','include','findAll','rows','catch','show','filtears','length','find','create','body','params','describe','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger'];(function(_0x2f827a,_0x158779){var _0x92f532=function(_0x28fa9f){while(--_0x28fa9f){_0x2f827a['push'](_0x2f827a['shift']());}};_0x92f532(++_0x158779);}(_0xeb38,0x1c8));var _0x8eb3=function(_0x220f3f,_0x11c540){_0x220f3f=_0x220f3f-0x0;var _0x1f170e=_0xeb38[_0x220f3f];return _0x1f170e;};'use strict';var pdf=require(_0x8eb3('0x0'));var emlformat=require(_0x8eb3('0x1'));var rimraf=require(_0x8eb3('0x2'));var zipdir=require(_0x8eb3('0x3'));var jsonpatch=require(_0x8eb3('0x4'));var rp=require(_0x8eb3('0x5'));var moment=require('moment');var BPromise=require(_0x8eb3('0x6'));var Mustache=require(_0x8eb3('0x7'));var util=require(_0x8eb3('0x8'));var path=require(_0x8eb3('0x9'));var sox=require(_0x8eb3('0xa'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x8eb3('0xb'));var squel=require(_0x8eb3('0xc'));var crypto=require(_0x8eb3('0xd'));var jsforce=require(_0x8eb3('0xe'));var deskjs=require(_0x8eb3('0xf'));var toCsv=require(_0x8eb3('0x10'));var querystring=require(_0x8eb3('0x11'));var Papa=require(_0x8eb3('0x12'));var Redis=require(_0x8eb3('0x13'));var authService=require(_0x8eb3('0x14'));var qs=require(_0x8eb3('0x15'));var as=require(_0x8eb3('0x16'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x8eb3('0x17'))(_0x8eb3('0x18'));var utils=require(_0x8eb3('0x19'));var config=require(_0x8eb3('0x1a'));var licenseUtil=require('../../config/license/util');var db=require(_0x8eb3('0x1b'))['db'];function respondWithStatusCode(_0x30af3c,_0x5926de){_0x5926de=_0x5926de||0xcc;return function(_0x273146){if(_0x273146){return _0x30af3c[_0x8eb3('0x1c')](_0x5926de);}return _0x30af3c['status'](_0x5926de)[_0x8eb3('0x1d')]();};}function respondWithResult(_0x3a3164,_0x443177){_0x443177=_0x443177||0xc8;return function(_0x390c2e){if(_0x390c2e){return _0x3a3164[_0x8eb3('0x1e')](_0x443177)['json'](_0x390c2e);}};}function respondWithFilteredResult(_0x2827e2,_0x435a43){return function(_0x252999){if(_0x252999){var _0x515ce6=_0x252999[_0x8eb3('0x1f')],_0x3ddcdf=_0x435a43[_0x8eb3('0x20')],_0x2f2337=_0x435a43[_0x8eb3('0x20')]+_0x435a43[_0x8eb3('0x21')],_0x5c3867;if(_0x2f2337>=_0x515ce6){_0x2f2337=_0x515ce6;_0x5c3867=0xc8;}else{_0x5c3867=0xce;}_0x2827e2[_0x8eb3('0x1e')](_0x5c3867);return _0x2827e2[_0x8eb3('0x22')](_0x8eb3('0x23'),_0x3ddcdf+'-'+_0x2f2337+'/'+_0x515ce6)[_0x8eb3('0x24')](_0x252999);}return null;};}function patchUpdates(_0x5bdd9a){return function(_0x4f1b62){try{jsonpatch[_0x8eb3('0x25')](_0x4f1b62,_0x5bdd9a,!![]);}catch(_0x27860c){return BPromise[_0x8eb3('0x26')](_0x27860c);}return _0x4f1b62[_0x8eb3('0x27')]();};}function saveUpdates(_0x29ce2e,_0x3dc616){return function(_0x40178b){if(_0x40178b){return _0x40178b[_0x8eb3('0x28')](_0x29ce2e)[_0x8eb3('0x29')](function(_0x20be8d){return _0x20be8d;});}return null;};}function removeEntity(_0x5776df,_0x4a1b6c){return function(_0x7bd393){if(_0x7bd393){return _0x7bd393[_0x8eb3('0x2a')]()[_0x8eb3('0x29')](function(){_0x5776df[_0x8eb3('0x1e')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2d9689,_0x202f51){return function(_0x382cf4){if(!_0x382cf4){_0x2d9689['sendStatus'](0x194);}return _0x382cf4;};}function handleError(_0x524a6a,_0x1b922d){_0x1b922d=_0x1b922d||0x1f4;return function(_0x1c9c04){logger['error'](_0x1c9c04[_0x8eb3('0x2b')]);if(_0x1c9c04[_0x8eb3('0x2c')]){delete _0x1c9c04['name'];}_0x524a6a[_0x8eb3('0x1e')](_0x1b922d)[_0x8eb3('0x2d')](_0x1c9c04);};}exports[_0x8eb3('0x2e')]=function(_0x3c5d42,_0x40f1b1){var _0x12eec9={},_0x8044bb={},_0x146f03={'count':0x0,'rows':[]};var _0x1a3f8d=_[_0x8eb3('0x2f')](db[_0x8eb3('0x30')][_0x8eb3('0x31')],function(_0x30d867){return{'name':_0x30d867[_0x8eb3('0x32')],'type':_0x30d867[_0x8eb3('0x33')][_0x8eb3('0x34')]};});_0x8044bb[_0x8eb3('0x35')]=_['map'](_0x1a3f8d,_0x8eb3('0x2c'));_0x8044bb[_0x8eb3('0x36')]=_[_0x8eb3('0x37')](_0x3c5d42[_0x8eb3('0x36')]);_0x8044bb['filters']=_['intersection'](_0x8044bb[_0x8eb3('0x35')],_0x8044bb['query']);_0x12eec9['attributes']=_[_0x8eb3('0x38')](_0x8044bb[_0x8eb3('0x35')],qs['fields'](_0x3c5d42[_0x8eb3('0x36')][_0x8eb3('0x39')]));_0x12eec9[_0x8eb3('0x3a')]=_0x12eec9[_0x8eb3('0x3a')]['length']?_0x12eec9[_0x8eb3('0x3a')]:_0x8044bb[_0x8eb3('0x35')];if(!_0x3c5d42['query'][_0x8eb3('0x3b')](_0x8eb3('0x3c'))){_0x12eec9[_0x8eb3('0x21')]=qs[_0x8eb3('0x21')](_0x3c5d42[_0x8eb3('0x36')][_0x8eb3('0x21')]);_0x12eec9['offset']=qs[_0x8eb3('0x20')](_0x3c5d42['query'][_0x8eb3('0x20')]);}_0x12eec9[_0x8eb3('0x3d')]=qs['sort'](_0x3c5d42['query'][_0x8eb3('0x3e')]);_0x12eec9[_0x8eb3('0x3f')]=qs[_0x8eb3('0x40')](_['pick'](_0x3c5d42[_0x8eb3('0x36')],_0x8044bb['filters']),_0x1a3f8d);if(_0x3c5d42[_0x8eb3('0x36')]['filter']){_0x12eec9[_0x8eb3('0x3f')]=_[_0x8eb3('0x41')](_0x12eec9[_0x8eb3('0x3f')],{'$or':_[_0x8eb3('0x2f')](_0x1a3f8d,function(_0x55962a){if(_0x55962a[_0x8eb3('0x33')]!==_0x8eb3('0x42')){var _0x1379fc={};_0x1379fc[_0x55962a[_0x8eb3('0x2c')]]={'$like':'%'+_0x3c5d42['query']['filter']+'%'};return _0x1379fc;}})});}_0x12eec9=_['merge']({},_0x12eec9,_0x3c5d42['options']);var _0x1c5d2f={'where':_0x12eec9['where']};return db[_0x8eb3('0x30')][_0x8eb3('0x1f')](_0x1c5d2f)['then'](function(_0x563eac){_0x146f03[_0x8eb3('0x1f')]=_0x563eac;if(_0x3c5d42[_0x8eb3('0x36')][_0x8eb3('0x43')]){_0x12eec9[_0x8eb3('0x44')]=[{'all':!![]}];}return db[_0x8eb3('0x30')][_0x8eb3('0x45')](_0x12eec9);})['then'](function(_0xa94800){_0x146f03[_0x8eb3('0x46')]=_0xa94800;return _0x146f03;})['then'](respondWithFilteredResult(_0x40f1b1,_0x12eec9))[_0x8eb3('0x47')](handleError(_0x40f1b1,null));};exports[_0x8eb3('0x48')]=function(_0x1895b6,_0x4af5ba){var _0x5f1dfc={'raw':![],'where':{'id':_0x1895b6['params']['id']}},_0x1189b5={};_0x1189b5[_0x8eb3('0x35')]=_[_0x8eb3('0x37')](db[_0x8eb3('0x30')]['rawAttributes']);_0x1189b5[_0x8eb3('0x36')]=_[_0x8eb3('0x37')](_0x1895b6[_0x8eb3('0x36')]);_0x1189b5[_0x8eb3('0x49')]=_[_0x8eb3('0x38')](_0x1189b5[_0x8eb3('0x35')],_0x1189b5[_0x8eb3('0x36')]);_0x5f1dfc[_0x8eb3('0x3a')]=_[_0x8eb3('0x38')](_0x1189b5[_0x8eb3('0x35')],qs[_0x8eb3('0x39')](_0x1895b6[_0x8eb3('0x36')]['fields']));_0x5f1dfc[_0x8eb3('0x3a')]=_0x5f1dfc[_0x8eb3('0x3a')][_0x8eb3('0x4a')]?_0x5f1dfc[_0x8eb3('0x3a')]:_0x1189b5[_0x8eb3('0x35')];if(_0x1895b6[_0x8eb3('0x36')]['includeAll']){_0x5f1dfc['include']=[{'all':!![]}];}_0x5f1dfc=_[_0x8eb3('0x41')]({},_0x5f1dfc,_0x1895b6['options']);return db[_0x8eb3('0x30')][_0x8eb3('0x4b')](_0x5f1dfc)[_0x8eb3('0x29')](handleEntityNotFound(_0x4af5ba,null))[_0x8eb3('0x29')](respondWithResult(_0x4af5ba,null))[_0x8eb3('0x47')](handleError(_0x4af5ba,null));};exports[_0x8eb3('0x4c')]=function(_0x24bff3,_0x101c68){return db[_0x8eb3('0x30')][_0x8eb3('0x4c')](_0x24bff3['body'],{})['then'](respondWithResult(_0x101c68,0xc9))['catch'](handleError(_0x101c68,null));};exports[_0x8eb3('0x28')]=function(_0x225eb9,_0x41fc6d){if(_0x225eb9[_0x8eb3('0x4d')]['id']){delete _0x225eb9['body']['id'];}return db['UserProfileSection'][_0x8eb3('0x4b')]({'where':{'id':_0x225eb9[_0x8eb3('0x4e')]['id']}})[_0x8eb3('0x29')](handleEntityNotFound(_0x41fc6d,null))[_0x8eb3('0x29')](saveUpdates(_0x225eb9[_0x8eb3('0x4d')],null))[_0x8eb3('0x29')](respondWithResult(_0x41fc6d,null))[_0x8eb3('0x47')](handleError(_0x41fc6d,null));};exports[_0x8eb3('0x2a')]=function(_0x2a3da5,_0x5b69fd){return db['UserProfileSection'][_0x8eb3('0x4b')]({'where':{'id':_0x2a3da5['params']['id']}})[_0x8eb3('0x29')](handleEntityNotFound(_0x5b69fd,null))[_0x8eb3('0x29')](removeEntity(_0x5b69fd,null))[_0x8eb3('0x47')](handleError(_0x5b69fd,null));};exports[_0x8eb3('0x4f')]=function(_0x51289,_0xcf9ba){return db['UserProfileSection'][_0x8eb3('0x4f')]()['then'](respondWithResult(_0xcf9ba,null))['catch'](handleError(_0xcf9ba,null));};