Built motion from commit (unavailable).|2.5.11
[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 _0xa0dd=['moment','bluebird','mustache','util','path','lodash','squel','crypto','to-csv','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','sendStatus','status','json','count','offset','limit','set','Content-Range','apply','reject','save','update','destroy','then','end','error','name','index','map','UserProfileSection','rawAttributes','fieldName','type','model','query','filters','intersection','attributes','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','options','includeAll','findAll','rows','catch','show','params','keys','fields','length','include','find','create','body','describe','html-pdf','eml-format','rimraf','fast-json-patch','request-promise'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xa0dd,0x172));var _0xda0d=function(_0x4bdf1b,_0x2ae1ba){_0x4bdf1b=_0x4bdf1b-0x0;var _0x169793=_0xa0dd[_0x4bdf1b];return _0x169793;};'use strict';var pdf=require(_0xda0d('0x0'));var emlformat=require(_0xda0d('0x1'));var rimraf=require(_0xda0d('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0xda0d('0x3'));var rp=require(_0xda0d('0x4'));var moment=require(_0xda0d('0x5'));var BPromise=require(_0xda0d('0x6'));var Mustache=require(_0xda0d('0x7'));var util=require(_0xda0d('0x8'));var path=require(_0xda0d('0x9'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0xda0d('0xa'));var squel=require(_0xda0d('0xb'));var crypto=require(_0xda0d('0xc'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xda0d('0xd'));var querystring=require(_0xda0d('0xe'));var Papa=require('papaparse');var Redis=require(_0xda0d('0xf'));var authService=require(_0xda0d('0x10'));var qs=require(_0xda0d('0x11'));var as=require(_0xda0d('0x12'));var hardwareService=require(_0xda0d('0x13'));var logger=require(_0xda0d('0x14'))(_0xda0d('0x15'));var utils=require('../../config/utils');var config=require(_0xda0d('0x16'));var licenseUtil=require(_0xda0d('0x17'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3edc5f,_0x1bb803){_0x1bb803=_0x1bb803||0xcc;return function(_0x391627){if(_0x391627){return _0x3edc5f[_0xda0d('0x18')](_0x1bb803);}return _0x3edc5f[_0xda0d('0x19')](_0x1bb803)['end']();};}function respondWithResult(_0x2186f4,_0x15c417){_0x15c417=_0x15c417||0xc8;return function(_0x350ace){if(_0x350ace){return _0x2186f4[_0xda0d('0x19')](_0x15c417)[_0xda0d('0x1a')](_0x350ace);}};}function respondWithFilteredResult(_0x1b3d9f,_0x51fc3f){return function(_0x3f68b9){if(_0x3f68b9){var _0x155fcb=_0x3f68b9[_0xda0d('0x1b')],_0x50b544=_0x51fc3f[_0xda0d('0x1c')],_0x2e27da=_0x51fc3f[_0xda0d('0x1c')]+_0x51fc3f[_0xda0d('0x1d')],_0x3ae71f;if(_0x2e27da>=_0x155fcb){_0x2e27da=_0x155fcb;_0x3ae71f=0xc8;}else{_0x3ae71f=0xce;}_0x1b3d9f[_0xda0d('0x19')](_0x3ae71f);return _0x1b3d9f[_0xda0d('0x1e')](_0xda0d('0x1f'),_0x50b544+'-'+_0x2e27da+'/'+_0x155fcb)[_0xda0d('0x1a')](_0x3f68b9);}return null;};}function patchUpdates(_0x5f2c19){return function(_0x46400b){try{jsonpatch[_0xda0d('0x20')](_0x46400b,_0x5f2c19,!![]);}catch(_0x2b6ea8){return BPromise[_0xda0d('0x21')](_0x2b6ea8);}return _0x46400b[_0xda0d('0x22')]();};}function saveUpdates(_0xdda438,_0x5fb9a2){return function(_0x2e1b2d){if(_0x2e1b2d){return _0x2e1b2d[_0xda0d('0x23')](_0xdda438)['then'](function(_0x14e3d5){return _0x14e3d5;});}return null;};}function removeEntity(_0x23ec7d,_0x4b8910){return function(_0xb7c7b7){if(_0xb7c7b7){return _0xb7c7b7[_0xda0d('0x24')]()[_0xda0d('0x25')](function(){_0x23ec7d[_0xda0d('0x19')](0xcc)[_0xda0d('0x26')]();});}};}function handleEntityNotFound(_0x2e89fe,_0x36a387){return function(_0x4b5592){if(!_0x4b5592){_0x2e89fe[_0xda0d('0x18')](0x194);}return _0x4b5592;};}function handleError(_0x5562b1,_0x280b0f){_0x280b0f=_0x280b0f||0x1f4;return function(_0x4ada6e){logger[_0xda0d('0x27')](_0x4ada6e['stack']);if(_0x4ada6e[_0xda0d('0x28')]){delete _0x4ada6e[_0xda0d('0x28')];}_0x5562b1['status'](_0x280b0f)['send'](_0x4ada6e);};}exports[_0xda0d('0x29')]=function(_0x2035be,_0x7335d7){var _0x19042b={},_0xb48a71={},_0x401af7={'count':0x0,'rows':[]};var _0xb7dcfe=_[_0xda0d('0x2a')](db[_0xda0d('0x2b')][_0xda0d('0x2c')],function(_0x4da102){return{'name':_0x4da102[_0xda0d('0x2d')],'type':_0x4da102[_0xda0d('0x2e')]['key']};});_0xb48a71[_0xda0d('0x2f')]=_['map'](_0xb7dcfe,'name');_0xb48a71[_0xda0d('0x30')]=_['keys'](_0x2035be[_0xda0d('0x30')]);_0xb48a71[_0xda0d('0x31')]=_[_0xda0d('0x32')](_0xb48a71[_0xda0d('0x2f')],_0xb48a71[_0xda0d('0x30')]);_0x19042b[_0xda0d('0x33')]=_[_0xda0d('0x32')](_0xb48a71[_0xda0d('0x2f')],qs['fields'](_0x2035be[_0xda0d('0x30')]['fields']));_0x19042b[_0xda0d('0x33')]=_0x19042b[_0xda0d('0x33')]['length']?_0x19042b[_0xda0d('0x33')]:_0xb48a71[_0xda0d('0x2f')];if(!_0x2035be[_0xda0d('0x30')]['hasOwnProperty'](_0xda0d('0x34'))){_0x19042b['limit']=qs[_0xda0d('0x1d')](_0x2035be[_0xda0d('0x30')]['limit']);_0x19042b[_0xda0d('0x1c')]=qs[_0xda0d('0x1c')](_0x2035be['query']['offset']);}_0x19042b[_0xda0d('0x35')]=qs[_0xda0d('0x36')](_0x2035be[_0xda0d('0x30')]['sort']);_0x19042b[_0xda0d('0x37')]=qs[_0xda0d('0x31')](_[_0xda0d('0x38')](_0x2035be[_0xda0d('0x30')],_0xb48a71[_0xda0d('0x31')]),_0xb7dcfe);if(_0x2035be[_0xda0d('0x30')]['filter']){_0x19042b[_0xda0d('0x37')]=_[_0xda0d('0x39')](_0x19042b[_0xda0d('0x37')],{'$or':_[_0xda0d('0x2a')](_0xb7dcfe,function(_0x2a5f0e){if(_0x2a5f0e[_0xda0d('0x2e')]!==_0xda0d('0x3a')){var _0x27dc39={};_0x27dc39[_0x2a5f0e['name']]={'$like':'%'+_0x2035be[_0xda0d('0x30')][_0xda0d('0x3b')]+'%'};return _0x27dc39;}})});}_0x19042b=_['merge']({},_0x19042b,_0x2035be[_0xda0d('0x3c')]);var _0x1e2036={'where':_0x19042b[_0xda0d('0x37')]};return db[_0xda0d('0x2b')][_0xda0d('0x1b')](_0x1e2036)[_0xda0d('0x25')](function(_0x36886e){_0x401af7[_0xda0d('0x1b')]=_0x36886e;if(_0x2035be[_0xda0d('0x30')][_0xda0d('0x3d')]){_0x19042b['include']=[{'all':!![]}];}return db['UserProfileSection'][_0xda0d('0x3e')](_0x19042b);})['then'](function(_0x18a1ec){_0x401af7[_0xda0d('0x3f')]=_0x18a1ec;return _0x401af7;})[_0xda0d('0x25')](respondWithFilteredResult(_0x7335d7,_0x19042b))[_0xda0d('0x40')](handleError(_0x7335d7,null));};exports[_0xda0d('0x41')]=function(_0x1abd89,_0x53da8f){var _0x32b94c={'raw':![],'where':{'id':_0x1abd89[_0xda0d('0x42')]['id']}},_0x4bbb7f={};_0x4bbb7f['model']=_[_0xda0d('0x43')](db[_0xda0d('0x2b')][_0xda0d('0x2c')]);_0x4bbb7f[_0xda0d('0x30')]=_[_0xda0d('0x43')](_0x1abd89[_0xda0d('0x30')]);_0x4bbb7f[_0xda0d('0x31')]=_[_0xda0d('0x32')](_0x4bbb7f[_0xda0d('0x2f')],_0x4bbb7f[_0xda0d('0x30')]);_0x32b94c[_0xda0d('0x33')]=_[_0xda0d('0x32')](_0x4bbb7f[_0xda0d('0x2f')],qs[_0xda0d('0x44')](_0x1abd89[_0xda0d('0x30')][_0xda0d('0x44')]));_0x32b94c[_0xda0d('0x33')]=_0x32b94c[_0xda0d('0x33')][_0xda0d('0x45')]?_0x32b94c[_0xda0d('0x33')]:_0x4bbb7f[_0xda0d('0x2f')];if(_0x1abd89[_0xda0d('0x30')][_0xda0d('0x3d')]){_0x32b94c[_0xda0d('0x46')]=[{'all':!![]}];}_0x32b94c=_[_0xda0d('0x39')]({},_0x32b94c,_0x1abd89[_0xda0d('0x3c')]);return db[_0xda0d('0x2b')][_0xda0d('0x47')](_0x32b94c)[_0xda0d('0x25')](handleEntityNotFound(_0x53da8f,null))[_0xda0d('0x25')](respondWithResult(_0x53da8f,null))[_0xda0d('0x40')](handleError(_0x53da8f,null));};exports[_0xda0d('0x48')]=function(_0x49a437,_0x749af8){return db[_0xda0d('0x2b')]['create'](_0x49a437[_0xda0d('0x49')],{})[_0xda0d('0x25')](respondWithResult(_0x749af8,0xc9))['catch'](handleError(_0x749af8,null));};exports[_0xda0d('0x23')]=function(_0x38f4bf,_0x3476bc){if(_0x38f4bf['body']['id']){delete _0x38f4bf[_0xda0d('0x49')]['id'];}return db[_0xda0d('0x2b')][_0xda0d('0x47')]({'where':{'id':_0x38f4bf[_0xda0d('0x42')]['id']}})[_0xda0d('0x25')](handleEntityNotFound(_0x3476bc,null))['then'](saveUpdates(_0x38f4bf[_0xda0d('0x49')],null))[_0xda0d('0x25')](respondWithResult(_0x3476bc,null))[_0xda0d('0x40')](handleError(_0x3476bc,null));};exports[_0xda0d('0x24')]=function(_0x4592d8,_0x2355be){return db[_0xda0d('0x2b')][_0xda0d('0x47')]({'where':{'id':_0x4592d8['params']['id']}})[_0xda0d('0x25')](handleEntityNotFound(_0x2355be,null))[_0xda0d('0x25')](removeEntity(_0x2355be,null))[_0xda0d('0x40')](handleError(_0x2355be,null));};exports[_0xda0d('0x4a')]=function(_0x15a6c0,_0x982bb3){return db[_0xda0d('0x2b')][_0xda0d('0x4a')]()[_0xda0d('0x25')](respondWithResult(_0x982bb3,null))[_0xda0d('0x40')](handleError(_0x982bb3,null));};