Built motion from commit (unavailable).|2.4.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 _0x5fc3=['length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','map','type','key','VIRTUAL','includeAll','findAll','rows','catch','show','params','include','create','body','find','describe','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','lodash','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../mysqldb','sendStatus','end','status','count','offset','limit','Content-Range','json','apply','reject','update','then','destroy','error','stack','name','index','UserProfileSection','model','keys','query','filters','intersection','attributes','fields'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x5fc3,0xa8));var _0x35fc=function(_0x53cf8e,_0x3d290f){_0x53cf8e=_0x53cf8e-0x0;var _0x459197=_0x5fc3[_0x53cf8e];return _0x459197;};'use strict';var pdf=require(_0x35fc('0x0'));var emlformat=require(_0x35fc('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x35fc('0x2'));var jsonpatch=require(_0x35fc('0x3'));var rp=require(_0x35fc('0x4'));var moment=require(_0x35fc('0x5'));var BPromise=require(_0x35fc('0x6'));var Mustache=require('mustache');var util=require(_0x35fc('0x7'));var path=require(_0x35fc('0x8'));var sox=require(_0x35fc('0x9'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x35fc('0xa'));var squel=require('squel');var crypto=require(_0x35fc('0xb'));var jsforce=require(_0x35fc('0xc'));var deskjs=require(_0x35fc('0xd'));var toCsv=require(_0x35fc('0xe'));var querystring=require(_0x35fc('0xf'));var Papa=require(_0x35fc('0x10'));var Redis=require(_0x35fc('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x35fc('0x12'));var hardwareService=require(_0x35fc('0x13'));var logger=require('../../config/logger')(_0x35fc('0x14'));var utils=require(_0x35fc('0x15'));var config=require('../../config/environment');var db=require(_0x35fc('0x16'))['db'];function respondWithStatusCode(_0x1a9f2b,_0x5469f5){_0x5469f5=_0x5469f5||0xcc;return function(_0x4cbe74){if(_0x4cbe74){return _0x1a9f2b[_0x35fc('0x17')](_0x5469f5);}return _0x1a9f2b['status'](_0x5469f5)[_0x35fc('0x18')]();};}function respondWithResult(_0x22055e,_0x2a6ad2){_0x2a6ad2=_0x2a6ad2||0xc8;return function(_0x29730f){if(_0x29730f){return _0x22055e[_0x35fc('0x19')](_0x2a6ad2)['json'](_0x29730f);}};}function respondWithFilteredResult(_0x59507a,_0x5eac0f){return function(_0x558364){if(_0x558364){var _0x398b67=_0x558364[_0x35fc('0x1a')],_0x229d56=_0x5eac0f[_0x35fc('0x1b')],_0x53b898=_0x5eac0f['offset']+_0x5eac0f[_0x35fc('0x1c')],_0x154958;if(_0x53b898>=_0x398b67){_0x53b898=_0x398b67;_0x154958=0xc8;}else{_0x154958=0xce;}_0x59507a[_0x35fc('0x19')](_0x154958);return _0x59507a['set'](_0x35fc('0x1d'),_0x229d56+'-'+_0x53b898+'/'+_0x398b67)[_0x35fc('0x1e')](_0x558364);}return null;};}function patchUpdates(_0x2e513b){return function(_0x5f56c6){try{jsonpatch[_0x35fc('0x1f')](_0x5f56c6,_0x2e513b,!![]);}catch(_0x3c58ea){return BPromise[_0x35fc('0x20')](_0x3c58ea);}return _0x5f56c6['save']();};}function saveUpdates(_0x402cff,_0x350a27){return function(_0x3229d1){if(_0x3229d1){return _0x3229d1[_0x35fc('0x21')](_0x402cff)[_0x35fc('0x22')](function(_0x21f1a9){return _0x21f1a9;});}return null;};}function removeEntity(_0x155016,_0x3b05b0){return function(_0x2405e8){if(_0x2405e8){return _0x2405e8[_0x35fc('0x23')]()['then'](function(){_0x155016[_0x35fc('0x19')](0xcc)[_0x35fc('0x18')]();});}};}function handleEntityNotFound(_0x257719,_0x2d8183){return function(_0x3b4743){if(!_0x3b4743){_0x257719['sendStatus'](0x194);}return _0x3b4743;};}function handleError(_0x33f5e8,_0x4c587a){_0x4c587a=_0x4c587a||0x1f4;return function(_0x561bf8){logger[_0x35fc('0x24')](_0x561bf8[_0x35fc('0x25')]);if(_0x561bf8[_0x35fc('0x26')]){delete _0x561bf8['name'];}_0x33f5e8[_0x35fc('0x19')](_0x4c587a)['send'](_0x561bf8);};}exports[_0x35fc('0x27')]=function(_0xdfab9f,_0x5cb986){var _0x519264={},_0x47774c={},_0x58edb6={'count':0x0,'rows':[]};var _0x274208=db[_0x35fc('0x28')]['rawAttributes'];_0x47774c[_0x35fc('0x29')]=_[_0x35fc('0x2a')](_0x274208);_0x47774c[_0x35fc('0x2b')]=_[_0x35fc('0x2a')](_0xdfab9f[_0x35fc('0x2b')]);_0x47774c[_0x35fc('0x2c')]=_[_0x35fc('0x2d')](_0x47774c[_0x35fc('0x29')],_0x47774c['query']);_0x519264[_0x35fc('0x2e')]=_[_0x35fc('0x2d')](_0x47774c[_0x35fc('0x29')],qs['fields'](_0xdfab9f[_0x35fc('0x2b')][_0x35fc('0x2f')]));_0x519264[_0x35fc('0x2e')]=_0x519264[_0x35fc('0x2e')][_0x35fc('0x30')]?_0x519264[_0x35fc('0x2e')]:_0x47774c[_0x35fc('0x29')];if(!_0xdfab9f[_0x35fc('0x2b')][_0x35fc('0x31')](_0x35fc('0x32'))){_0x519264['limit']=qs['limit'](_0xdfab9f[_0x35fc('0x2b')]['limit']);_0x519264[_0x35fc('0x1b')]=qs[_0x35fc('0x1b')](_0xdfab9f[_0x35fc('0x2b')][_0x35fc('0x1b')]);}_0x519264[_0x35fc('0x33')]=qs[_0x35fc('0x34')](_0xdfab9f['query'][_0x35fc('0x34')]);_0x519264[_0x35fc('0x35')]=qs[_0x35fc('0x2c')](_[_0x35fc('0x36')](_0xdfab9f[_0x35fc('0x2b')],_0x47774c[_0x35fc('0x2c')]));if(_0xdfab9f['query'][_0x35fc('0x37')]){_0x519264[_0x35fc('0x35')]=_[_0x35fc('0x38')](_0x519264['where'],{'$or':_[_0x35fc('0x39')](_0x274208,function(_0x48d223){if(_0x48d223[_0x35fc('0x3a')][_0x35fc('0x3b')]!==_0x35fc('0x3c')){var _0x2e00e3={};_0x2e00e3[_0x48d223['field']]={'$like':'%'+_0xdfab9f['query']['filter']+'%'};return _0x2e00e3;}})});}_0x519264=_[_0x35fc('0x38')]({},_0x519264,_0xdfab9f['options']);var _0x20f8bb={'where':_0x519264['where']};return db[_0x35fc('0x28')][_0x35fc('0x1a')](_0x20f8bb)[_0x35fc('0x22')](function(_0x22b724){_0x58edb6[_0x35fc('0x1a')]=_0x22b724;if(_0xdfab9f[_0x35fc('0x2b')][_0x35fc('0x3d')]){_0x519264['include']=[{'all':!![]}];}return db[_0x35fc('0x28')][_0x35fc('0x3e')](_0x519264);})['then'](function(_0x1feda5){_0x58edb6[_0x35fc('0x3f')]=_0x1feda5;return _0x58edb6;})[_0x35fc('0x22')](respondWithFilteredResult(_0x5cb986,_0x519264))[_0x35fc('0x40')](handleError(_0x5cb986,null));};exports[_0x35fc('0x41')]=function(_0x31d926,_0x58f25c){var _0x3f6480={'raw':![],'where':{'id':_0x31d926[_0x35fc('0x42')]['id']}},_0x267858={};_0x267858['model']=_[_0x35fc('0x2a')](db[_0x35fc('0x28')]['rawAttributes']);_0x267858[_0x35fc('0x2b')]=_[_0x35fc('0x2a')](_0x31d926[_0x35fc('0x2b')]);_0x267858[_0x35fc('0x2c')]=_[_0x35fc('0x2d')](_0x267858[_0x35fc('0x29')],_0x267858[_0x35fc('0x2b')]);_0x3f6480[_0x35fc('0x2e')]=_['intersection'](_0x267858['model'],qs[_0x35fc('0x2f')](_0x31d926[_0x35fc('0x2b')]['fields']));_0x3f6480['attributes']=_0x3f6480['attributes'][_0x35fc('0x30')]?_0x3f6480[_0x35fc('0x2e')]:_0x267858['model'];if(_0x31d926[_0x35fc('0x2b')][_0x35fc('0x3d')]){_0x3f6480[_0x35fc('0x43')]=[{'all':!![]}];}_0x3f6480=_[_0x35fc('0x38')]({},_0x3f6480,_0x31d926['options']);return db['UserProfileSection']['find'](_0x3f6480)['then'](handleEntityNotFound(_0x58f25c,null))['then'](respondWithResult(_0x58f25c,null))[_0x35fc('0x40')](handleError(_0x58f25c,null));};exports[_0x35fc('0x44')]=function(_0x4fc5bc,_0x119925){return db['UserProfileSection'][_0x35fc('0x44')](_0x4fc5bc[_0x35fc('0x45')],{})[_0x35fc('0x22')](respondWithResult(_0x119925,0xc9))[_0x35fc('0x40')](handleError(_0x119925,null));};exports[_0x35fc('0x21')]=function(_0x5d3d0f,_0x64d381){if(_0x5d3d0f[_0x35fc('0x45')]['id']){delete _0x5d3d0f['body']['id'];}return db[_0x35fc('0x28')][_0x35fc('0x46')]({'where':{'id':_0x5d3d0f[_0x35fc('0x42')]['id']}})[_0x35fc('0x22')](handleEntityNotFound(_0x64d381,null))['then'](saveUpdates(_0x5d3d0f[_0x35fc('0x45')],null))['then'](respondWithResult(_0x64d381,null))['catch'](handleError(_0x64d381,null));};exports[_0x35fc('0x23')]=function(_0x9db7e8,_0x18dc78){return db[_0x35fc('0x28')][_0x35fc('0x46')]({'where':{'id':_0x9db7e8[_0x35fc('0x42')]['id']}})[_0x35fc('0x22')](handleEntityNotFound(_0x18dc78,null))[_0x35fc('0x22')](removeEntity(_0x18dc78,null))['catch'](handleError(_0x18dc78,null));};exports[_0x35fc('0x47')]=function(_0x91d7c0,_0xeca02e){return db[_0x35fc('0x28')][_0x35fc('0x47')]()[_0x35fc('0x22')](respondWithResult(_0xeca02e,null))[_0x35fc('0x40')](handleError(_0xeca02e,null));};