Built motion from commit (unavailable).|2.5.4
[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 _0xf72f=['catch','show','params','length','includeAll','create','body','find','describe','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','lodash','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/utils','../../mysqldb','sendStatus','status','end','json','count','offset','set','Content-Range','apply','save','update','then','error','name','send','index','map','rawAttributes','fieldName','key','model','query','keys','intersection','attributes','fields','hasOwnProperty','nolimit','limit','order','sort','where','filters','filter','merge','type','VIRTUAL','UserProfileSection','include','findAll','rows'];(function(_0x8dd519,_0x2f5484){var _0x267c69=function(_0x181b42){while(--_0x181b42){_0x8dd519['push'](_0x8dd519['shift']());}};_0x267c69(++_0x2f5484);}(_0xf72f,0x171));var _0xff72=function(_0x42ef75,_0x2279fa){_0x42ef75=_0x42ef75-0x0;var _0x31571b=_0xf72f[_0x42ef75];return _0x31571b;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xff72('0x0'));var rimraf=require(_0xff72('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xff72('0x2'));var rp=require(_0xff72('0x3'));var moment=require(_0xff72('0x4'));var BPromise=require(_0xff72('0x5'));var Mustache=require(_0xff72('0x6'));var util=require(_0xff72('0x7'));var path=require(_0xff72('0x8'));var sox=require(_0xff72('0x9'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0xff72('0xa'));var squel=require('squel');var crypto=require(_0xff72('0xb'));var jsforce=require(_0xff72('0xc'));var deskjs=require(_0xff72('0xd'));var toCsv=require(_0xff72('0xe'));var querystring=require(_0xff72('0xf'));var Papa=require(_0xff72('0x10'));var Redis=require(_0xff72('0x11'));var authService=require('../../components/auth/service');var qs=require(_0xff72('0x12'));var as=require(_0xff72('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require(_0xff72('0x14'));var config=require('../../config/environment');var db=require(_0xff72('0x15'))['db'];function respondWithStatusCode(_0x5cd1f4,_0x4c720a){_0x4c720a=_0x4c720a||0xcc;return function(_0x3a2744){if(_0x3a2744){return _0x5cd1f4[_0xff72('0x16')](_0x4c720a);}return _0x5cd1f4[_0xff72('0x17')](_0x4c720a)[_0xff72('0x18')]();};}function respondWithResult(_0x56a9f4,_0x22dabc){_0x22dabc=_0x22dabc||0xc8;return function(_0x50cd3f){if(_0x50cd3f){return _0x56a9f4['status'](_0x22dabc)[_0xff72('0x19')](_0x50cd3f);}};}function respondWithFilteredResult(_0x2a1c39,_0x43ec9b){return function(_0x30d10c){if(_0x30d10c){var _0xf7b15e=_0x30d10c[_0xff72('0x1a')],_0x2f7385=_0x43ec9b[_0xff72('0x1b')],_0x4d7514=_0x43ec9b[_0xff72('0x1b')]+_0x43ec9b['limit'],_0x40b2de;if(_0x4d7514>=_0xf7b15e){_0x4d7514=_0xf7b15e;_0x40b2de=0xc8;}else{_0x40b2de=0xce;}_0x2a1c39[_0xff72('0x17')](_0x40b2de);return _0x2a1c39[_0xff72('0x1c')](_0xff72('0x1d'),_0x2f7385+'-'+_0x4d7514+'/'+_0xf7b15e)[_0xff72('0x19')](_0x30d10c);}return null;};}function patchUpdates(_0x532cee){return function(_0x50d996){try{jsonpatch[_0xff72('0x1e')](_0x50d996,_0x532cee,!![]);}catch(_0x292558){return BPromise['reject'](_0x292558);}return _0x50d996[_0xff72('0x1f')]();};}function saveUpdates(_0x28ae2b,_0x12ed64){return function(_0x5dad57){if(_0x5dad57){return _0x5dad57[_0xff72('0x20')](_0x28ae2b)['then'](function(_0x4e3b7f){return _0x4e3b7f;});}return null;};}function removeEntity(_0x46b096,_0x218336){return function(_0x52bc46){if(_0x52bc46){return _0x52bc46['destroy']()[_0xff72('0x21')](function(){_0x46b096[_0xff72('0x17')](0xcc)[_0xff72('0x18')]();});}};}function handleEntityNotFound(_0x654882,_0x23c2ba){return function(_0x147af0){if(!_0x147af0){_0x654882[_0xff72('0x16')](0x194);}return _0x147af0;};}function handleError(_0x4d3a8c,_0x51f5db){_0x51f5db=_0x51f5db||0x1f4;return function(_0x192f32){logger[_0xff72('0x22')](_0x192f32['stack']);if(_0x192f32[_0xff72('0x23')]){delete _0x192f32['name'];}_0x4d3a8c[_0xff72('0x17')](_0x51f5db)[_0xff72('0x24')](_0x192f32);};}exports[_0xff72('0x25')]=function(_0x13b910,_0x63c267){var _0xf8ce1c={},_0x21e0fe={},_0x1e2b62={'count':0x0,'rows':[]};var _0x161571=_[_0xff72('0x26')](db['UserProfileSection'][_0xff72('0x27')],function(_0x2c8631){return{'name':_0x2c8631[_0xff72('0x28')],'type':_0x2c8631['type'][_0xff72('0x29')]};});_0x21e0fe[_0xff72('0x2a')]=_['map'](_0x161571,_0xff72('0x23'));_0x21e0fe[_0xff72('0x2b')]=_[_0xff72('0x2c')](_0x13b910[_0xff72('0x2b')]);_0x21e0fe['filters']=_[_0xff72('0x2d')](_0x21e0fe[_0xff72('0x2a')],_0x21e0fe[_0xff72('0x2b')]);_0xf8ce1c[_0xff72('0x2e')]=_['intersection'](_0x21e0fe[_0xff72('0x2a')],qs[_0xff72('0x2f')](_0x13b910['query'][_0xff72('0x2f')]));_0xf8ce1c[_0xff72('0x2e')]=_0xf8ce1c['attributes']['length']?_0xf8ce1c[_0xff72('0x2e')]:_0x21e0fe[_0xff72('0x2a')];if(!_0x13b910[_0xff72('0x2b')][_0xff72('0x30')](_0xff72('0x31'))){_0xf8ce1c[_0xff72('0x32')]=qs[_0xff72('0x32')](_0x13b910[_0xff72('0x2b')][_0xff72('0x32')]);_0xf8ce1c[_0xff72('0x1b')]=qs[_0xff72('0x1b')](_0x13b910[_0xff72('0x2b')][_0xff72('0x1b')]);}_0xf8ce1c[_0xff72('0x33')]=qs[_0xff72('0x34')](_0x13b910['query'][_0xff72('0x34')]);_0xf8ce1c[_0xff72('0x35')]=qs[_0xff72('0x36')](_['pick'](_0x13b910[_0xff72('0x2b')],_0x21e0fe[_0xff72('0x36')]),_0x161571);if(_0x13b910['query'][_0xff72('0x37')]){_0xf8ce1c[_0xff72('0x35')]=_[_0xff72('0x38')](_0xf8ce1c[_0xff72('0x35')],{'$or':_['map'](_0x161571,function(_0x481866){if(_0x481866[_0xff72('0x39')]!==_0xff72('0x3a')){var _0xe9068={};_0xe9068[_0x481866[_0xff72('0x23')]]={'$like':'%'+_0x13b910[_0xff72('0x2b')]['filter']+'%'};return _0xe9068;}})});}_0xf8ce1c=_[_0xff72('0x38')]({},_0xf8ce1c,_0x13b910['options']);var _0x2c04ed={'where':_0xf8ce1c[_0xff72('0x35')]};return db[_0xff72('0x3b')][_0xff72('0x1a')](_0x2c04ed)['then'](function(_0x1432c3){_0x1e2b62[_0xff72('0x1a')]=_0x1432c3;if(_0x13b910[_0xff72('0x2b')]['includeAll']){_0xf8ce1c[_0xff72('0x3c')]=[{'all':!![]}];}return db[_0xff72('0x3b')][_0xff72('0x3d')](_0xf8ce1c);})[_0xff72('0x21')](function(_0xd19d7a){_0x1e2b62[_0xff72('0x3e')]=_0xd19d7a;return _0x1e2b62;})[_0xff72('0x21')](respondWithFilteredResult(_0x63c267,_0xf8ce1c))[_0xff72('0x3f')](handleError(_0x63c267,null));};exports[_0xff72('0x40')]=function(_0x4428b7,_0x3f33e9){var _0x4c534e={'raw':![],'where':{'id':_0x4428b7[_0xff72('0x41')]['id']}},_0x24c09e={};_0x24c09e['model']=_[_0xff72('0x2c')](db[_0xff72('0x3b')][_0xff72('0x27')]);_0x24c09e['query']=_[_0xff72('0x2c')](_0x4428b7[_0xff72('0x2b')]);_0x24c09e[_0xff72('0x36')]=_[_0xff72('0x2d')](_0x24c09e['model'],_0x24c09e[_0xff72('0x2b')]);_0x4c534e['attributes']=_[_0xff72('0x2d')](_0x24c09e['model'],qs[_0xff72('0x2f')](_0x4428b7[_0xff72('0x2b')][_0xff72('0x2f')]));_0x4c534e[_0xff72('0x2e')]=_0x4c534e[_0xff72('0x2e')][_0xff72('0x42')]?_0x4c534e['attributes']:_0x24c09e[_0xff72('0x2a')];if(_0x4428b7[_0xff72('0x2b')][_0xff72('0x43')]){_0x4c534e['include']=[{'all':!![]}];}_0x4c534e=_[_0xff72('0x38')]({},_0x4c534e,_0x4428b7['options']);return db[_0xff72('0x3b')]['find'](_0x4c534e)['then'](handleEntityNotFound(_0x3f33e9,null))['then'](respondWithResult(_0x3f33e9,null))[_0xff72('0x3f')](handleError(_0x3f33e9,null));};exports[_0xff72('0x44')]=function(_0x264df6,_0x4c5a90){return db['UserProfileSection'][_0xff72('0x44')](_0x264df6[_0xff72('0x45')],{})[_0xff72('0x21')](respondWithResult(_0x4c5a90,0xc9))[_0xff72('0x3f')](handleError(_0x4c5a90,null));};exports['update']=function(_0x399683,_0x53d30a){if(_0x399683[_0xff72('0x45')]['id']){delete _0x399683[_0xff72('0x45')]['id'];}return db['UserProfileSection'][_0xff72('0x46')]({'where':{'id':_0x399683[_0xff72('0x41')]['id']}})[_0xff72('0x21')](handleEntityNotFound(_0x53d30a,null))['then'](saveUpdates(_0x399683['body'],null))['then'](respondWithResult(_0x53d30a,null))[_0xff72('0x3f')](handleError(_0x53d30a,null));};exports['destroy']=function(_0x2dd3d6,_0x4c8dd2){return db['UserProfileSection'][_0xff72('0x46')]({'where':{'id':_0x2dd3d6[_0xff72('0x41')]['id']}})['then'](handleEntityNotFound(_0x4c8dd2,null))[_0xff72('0x21')](removeEntity(_0x4c8dd2,null))['catch'](handleError(_0x4c8dd2,null));};exports[_0xff72('0x47')]=function(_0x538730,_0x1e433a){return db[_0xff72('0x3b')][_0xff72('0x47')]()[_0xff72('0x21')](respondWithResult(_0x1e433a,null))[_0xff72('0x3f')](handleError(_0x1e433a,null));};