Built motion from commit (unavailable).|2.5.23
[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 _0xf911=['rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','end','status','json','count','limit','set','Content-Range','apply','reject','then','sendStatus','stack','name','send','map','fieldName','type','key','model','query','keys','intersection','fields','attributes','length','nolimit','offset','order','where','pick','filters','filter','VIRTUAL','merge','options','UserProfileSection','includeAll','findAll','rows','catch','show','params','include','create','body','update','find','destroy','html-pdf','eml-format'];(function(_0x54ac41,_0x4d1bc6){var _0x5bd9bf=function(_0x2fed46){while(--_0x2fed46){_0x54ac41['push'](_0x54ac41['shift']());}};_0x5bd9bf(++_0x4d1bc6);}(_0xf911,0xe2));var _0x1f91=function(_0x580c7f,_0x2ecf18){_0x580c7f=_0x580c7f-0x0;var _0x3b90e1=_0xf911[_0x580c7f];return _0x3b90e1;};'use strict';var pdf=require(_0x1f91('0x0'));var emlformat=require(_0x1f91('0x1'));var rimraf=require(_0x1f91('0x2'));var zipdir=require(_0x1f91('0x3'));var jsonpatch=require(_0x1f91('0x4'));var rp=require(_0x1f91('0x5'));var moment=require(_0x1f91('0x6'));var BPromise=require(_0x1f91('0x7'));var Mustache=require('mustache');var util=require(_0x1f91('0x8'));var path=require(_0x1f91('0x9'));var sox=require(_0x1f91('0xa'));var csv=require(_0x1f91('0xb'));var ejs=require(_0x1f91('0xc'));var fs=require('fs');var _=require(_0x1f91('0xd'));var squel=require(_0x1f91('0xe'));var crypto=require('crypto');var jsforce=require(_0x1f91('0xf'));var deskjs=require(_0x1f91('0x10'));var toCsv=require(_0x1f91('0xb'));var querystring=require(_0x1f91('0x11'));var Papa=require(_0x1f91('0x12'));var Redis=require(_0x1f91('0x13'));var authService=require(_0x1f91('0x14'));var qs=require(_0x1f91('0x15'));var as=require(_0x1f91('0x16'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x1f91('0x17'))(_0x1f91('0x18'));var utils=require(_0x1f91('0x19'));var config=require(_0x1f91('0x1a'));var licenseUtil=require(_0x1f91('0x1b'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0xb538a7,_0xf38020){_0xf38020=_0xf38020||0xcc;return function(_0x1c9de4){if(_0x1c9de4){return _0xb538a7['sendStatus'](_0xf38020);}return _0xb538a7['status'](_0xf38020)[_0x1f91('0x1c')]();};}function respondWithResult(_0x58100c,_0x4a93f1){_0x4a93f1=_0x4a93f1||0xc8;return function(_0x562870){if(_0x562870){return _0x58100c[_0x1f91('0x1d')](_0x4a93f1)[_0x1f91('0x1e')](_0x562870);}};}function respondWithFilteredResult(_0x48b387,_0x39b34e){return function(_0x4e575e){if(_0x4e575e){var _0x26bbe0=_0x4e575e[_0x1f91('0x1f')],_0x248882=_0x39b34e['offset'],_0x1e495a=_0x39b34e['offset']+_0x39b34e[_0x1f91('0x20')],_0x37e4aa;if(_0x1e495a>=_0x26bbe0){_0x1e495a=_0x26bbe0;_0x37e4aa=0xc8;}else{_0x37e4aa=0xce;}_0x48b387[_0x1f91('0x1d')](_0x37e4aa);return _0x48b387[_0x1f91('0x21')](_0x1f91('0x22'),_0x248882+'-'+_0x1e495a+'/'+_0x26bbe0)[_0x1f91('0x1e')](_0x4e575e);}return null;};}function patchUpdates(_0x1f69ac){return function(_0x430675){try{jsonpatch[_0x1f91('0x23')](_0x430675,_0x1f69ac,!![]);}catch(_0x138444){return BPromise[_0x1f91('0x24')](_0x138444);}return _0x430675['save']();};}function saveUpdates(_0x512c00,_0x43353f){return function(_0x74625f){if(_0x74625f){return _0x74625f['update'](_0x512c00)[_0x1f91('0x25')](function(_0x29b8ec){return _0x29b8ec;});}return null;};}function removeEntity(_0x10ec47,_0x49f246){return function(_0x3e2c60){if(_0x3e2c60){return _0x3e2c60['destroy']()[_0x1f91('0x25')](function(){_0x10ec47[_0x1f91('0x1d')](0xcc)[_0x1f91('0x1c')]();});}};}function handleEntityNotFound(_0x1ba914,_0x2e3e5){return function(_0x24b59f){if(!_0x24b59f){_0x1ba914[_0x1f91('0x26')](0x194);}return _0x24b59f;};}function handleError(_0x2cff99,_0x40dab2){_0x40dab2=_0x40dab2||0x1f4;return function(_0x575886){logger['error'](_0x575886[_0x1f91('0x27')]);if(_0x575886[_0x1f91('0x28')]){delete _0x575886[_0x1f91('0x28')];}_0x2cff99[_0x1f91('0x1d')](_0x40dab2)[_0x1f91('0x29')](_0x575886);};}exports['index']=function(_0x11e784,_0xfc0b1b){var _0x44b1c2={},_0x4f4f61={},_0x3207b3={'count':0x0,'rows':[]};var _0x4d983b=_[_0x1f91('0x2a')](db['UserProfileSection']['rawAttributes'],function(_0x838277){return{'name':_0x838277[_0x1f91('0x2b')],'type':_0x838277[_0x1f91('0x2c')][_0x1f91('0x2d')]};});_0x4f4f61[_0x1f91('0x2e')]=_[_0x1f91('0x2a')](_0x4d983b,_0x1f91('0x28'));_0x4f4f61[_0x1f91('0x2f')]=_[_0x1f91('0x30')](_0x11e784[_0x1f91('0x2f')]);_0x4f4f61['filters']=_[_0x1f91('0x31')](_0x4f4f61[_0x1f91('0x2e')],_0x4f4f61[_0x1f91('0x2f')]);_0x44b1c2['attributes']=_[_0x1f91('0x31')](_0x4f4f61[_0x1f91('0x2e')],qs['fields'](_0x11e784['query'][_0x1f91('0x32')]));_0x44b1c2[_0x1f91('0x33')]=_0x44b1c2[_0x1f91('0x33')][_0x1f91('0x34')]?_0x44b1c2[_0x1f91('0x33')]:_0x4f4f61[_0x1f91('0x2e')];if(!_0x11e784[_0x1f91('0x2f')]['hasOwnProperty'](_0x1f91('0x35'))){_0x44b1c2[_0x1f91('0x20')]=qs[_0x1f91('0x20')](_0x11e784[_0x1f91('0x2f')][_0x1f91('0x20')]);_0x44b1c2[_0x1f91('0x36')]=qs[_0x1f91('0x36')](_0x11e784[_0x1f91('0x2f')][_0x1f91('0x36')]);}_0x44b1c2[_0x1f91('0x37')]=qs['sort'](_0x11e784[_0x1f91('0x2f')]['sort']);_0x44b1c2[_0x1f91('0x38')]=qs['filters'](_[_0x1f91('0x39')](_0x11e784[_0x1f91('0x2f')],_0x4f4f61[_0x1f91('0x3a')]),_0x4d983b);if(_0x11e784[_0x1f91('0x2f')][_0x1f91('0x3b')]){_0x44b1c2[_0x1f91('0x38')]=_['merge'](_0x44b1c2[_0x1f91('0x38')],{'$or':_[_0x1f91('0x2a')](_0x4d983b,function(_0x35cec7){if(_0x35cec7[_0x1f91('0x2c')]!==_0x1f91('0x3c')){var _0x29c2b4={};_0x29c2b4[_0x35cec7['name']]={'$like':'%'+_0x11e784['query'][_0x1f91('0x3b')]+'%'};return _0x29c2b4;}})});}_0x44b1c2=_[_0x1f91('0x3d')]({},_0x44b1c2,_0x11e784[_0x1f91('0x3e')]);var _0x330bd4={'where':_0x44b1c2[_0x1f91('0x38')]};return db[_0x1f91('0x3f')][_0x1f91('0x1f')](_0x330bd4)[_0x1f91('0x25')](function(_0x3f4e0d){_0x3207b3[_0x1f91('0x1f')]=_0x3f4e0d;if(_0x11e784['query'][_0x1f91('0x40')]){_0x44b1c2['include']=[{'all':!![]}];}return db[_0x1f91('0x3f')][_0x1f91('0x41')](_0x44b1c2);})[_0x1f91('0x25')](function(_0x1eef51){_0x3207b3[_0x1f91('0x42')]=_0x1eef51;return _0x3207b3;})[_0x1f91('0x25')](respondWithFilteredResult(_0xfc0b1b,_0x44b1c2))[_0x1f91('0x43')](handleError(_0xfc0b1b,null));};exports[_0x1f91('0x44')]=function(_0x24f8e6,_0x365c9e){var _0x2c04db={'raw':![],'where':{'id':_0x24f8e6[_0x1f91('0x45')]['id']}},_0x31a55f={};_0x31a55f[_0x1f91('0x2e')]=_[_0x1f91('0x30')](db['UserProfileSection']['rawAttributes']);_0x31a55f[_0x1f91('0x2f')]=_[_0x1f91('0x30')](_0x24f8e6['query']);_0x31a55f[_0x1f91('0x3a')]=_[_0x1f91('0x31')](_0x31a55f[_0x1f91('0x2e')],_0x31a55f['query']);_0x2c04db[_0x1f91('0x33')]=_[_0x1f91('0x31')](_0x31a55f['model'],qs['fields'](_0x24f8e6[_0x1f91('0x2f')][_0x1f91('0x32')]));_0x2c04db['attributes']=_0x2c04db[_0x1f91('0x33')][_0x1f91('0x34')]?_0x2c04db[_0x1f91('0x33')]:_0x31a55f[_0x1f91('0x2e')];if(_0x24f8e6[_0x1f91('0x2f')][_0x1f91('0x40')]){_0x2c04db[_0x1f91('0x46')]=[{'all':!![]}];}_0x2c04db=_[_0x1f91('0x3d')]({},_0x2c04db,_0x24f8e6[_0x1f91('0x3e')]);return db['UserProfileSection']['find'](_0x2c04db)[_0x1f91('0x25')](handleEntityNotFound(_0x365c9e,null))['then'](respondWithResult(_0x365c9e,null))[_0x1f91('0x43')](handleError(_0x365c9e,null));};exports['create']=function(_0x497ba5,_0x46f735){return db[_0x1f91('0x3f')][_0x1f91('0x47')](_0x497ba5[_0x1f91('0x48')],{})['then'](respondWithResult(_0x46f735,0xc9))[_0x1f91('0x43')](handleError(_0x46f735,null));};exports[_0x1f91('0x49')]=function(_0x4e32bf,_0x5407d1){if(_0x4e32bf['body']['id']){delete _0x4e32bf[_0x1f91('0x48')]['id'];}return db[_0x1f91('0x3f')][_0x1f91('0x4a')]({'where':{'id':_0x4e32bf[_0x1f91('0x45')]['id']}})[_0x1f91('0x25')](handleEntityNotFound(_0x5407d1,null))[_0x1f91('0x25')](saveUpdates(_0x4e32bf[_0x1f91('0x48')],null))[_0x1f91('0x25')](respondWithResult(_0x5407d1,null))['catch'](handleError(_0x5407d1,null));};exports[_0x1f91('0x4b')]=function(_0x2ffa81,_0x3bd24f){return db[_0x1f91('0x3f')]['find']({'where':{'id':_0x2ffa81[_0x1f91('0x45')]['id']}})[_0x1f91('0x25')](handleEntityNotFound(_0x3bd24f,null))[_0x1f91('0x25')](removeEntity(_0x3bd24f,null))[_0x1f91('0x43')](handleError(_0x3bd24f,null));};exports['describe']=function(_0x5f2c8f,_0x4883d0){return db['UserProfileSection']['describe']()[_0x1f91('0x25')](respondWithResult(_0x4883d0,null))[_0x1f91('0x43')](handleError(_0x4883d0,null));};