Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / license / license.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 _0x113f=['lodash','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../mysqldb','sendStatus','end','status','json','count','offset','limit','set','apply','reject','save','update','then','destroy','error','stack','name','send','../../config/license/util','index','model','rawAttributes','query','filters','intersection','attributes','length','options','getLicense','catch','body','License','find','params','get','checkLicense','key','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv'];(function(_0x328685,_0x50a3b9){var _0x569d49=function(_0x1b13ce){while(--_0x1b13ce){_0x328685['push'](_0x328685['shift']());}};_0x569d49(++_0x50a3b9);}(_0x113f,0x198));var _0xf113=function(_0x336c8b,_0x56b55b){_0x336c8b=_0x336c8b-0x0;var _0x4dd2f6=_0x113f[_0x336c8b];return _0x4dd2f6;};'use strict';var pdf=require(_0xf113('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xf113('0x1'));var zipdir=require(_0xf113('0x2'));var jsonpatch=require(_0xf113('0x3'));var rp=require(_0xf113('0x4'));var moment=require(_0xf113('0x5'));var BPromise=require(_0xf113('0x6'));var Mustache=require(_0xf113('0x7'));var util=require(_0xf113('0x8'));var path=require(_0xf113('0x9'));var sox=require(_0xf113('0xa'));var csv=require(_0xf113('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xf113('0xc'));var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0xf113('0xd'));var toCsv=require('to-csv');var querystring=require(_0xf113('0xe'));var Papa=require(_0xf113('0xf'));var Redis=require(_0xf113('0x10'));var authService=require(_0xf113('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0xf113('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf113('0x13'))(_0xf113('0x14'));var utils=require('../../config/utils');var config=require(_0xf113('0x15'));var db=require(_0xf113('0x16'))['db'];function respondWithStatusCode(_0x31d93c,_0x3d3904){_0x3d3904=_0x3d3904||0xcc;return function(_0x327fe2){if(_0x327fe2){return _0x31d93c[_0xf113('0x17')](_0x3d3904);}return _0x31d93c['status'](_0x3d3904)[_0xf113('0x18')]();};}function respondWithResult(_0x41c069,_0x5c30ed){_0x5c30ed=_0x5c30ed||0xc8;return function(_0x25d43f){if(_0x25d43f){return _0x41c069[_0xf113('0x19')](_0x5c30ed)[_0xf113('0x1a')](_0x25d43f);}};}function respondWithFilteredResult(_0x5d0ec2,_0x39f19c){return function(_0x4900d9){if(_0x4900d9){var _0x3a453e=_0x4900d9[_0xf113('0x1b')],_0x152f68=_0x39f19c[_0xf113('0x1c')],_0x118425=_0x39f19c[_0xf113('0x1c')]+_0x39f19c[_0xf113('0x1d')],_0x3ea5df;if(_0x118425>=_0x3a453e){_0x118425=_0x3a453e;_0x3ea5df=0xc8;}else{_0x3ea5df=0xce;}_0x5d0ec2[_0xf113('0x19')](_0x3ea5df);return _0x5d0ec2[_0xf113('0x1e')]('Content-Range',_0x152f68+'-'+_0x118425+'/'+_0x3a453e)[_0xf113('0x1a')](_0x4900d9);}return null;};}function patchUpdates(_0x1b053a){return function(_0x3014ff){try{jsonpatch[_0xf113('0x1f')](_0x3014ff,_0x1b053a,!![]);}catch(_0x458c07){return BPromise[_0xf113('0x20')](_0x458c07);}return _0x3014ff[_0xf113('0x21')]();};}function saveUpdates(_0x5789ae,_0x12e8a5){return function(_0x161306){if(_0x161306){return _0x161306[_0xf113('0x22')](_0x5789ae)[_0xf113('0x23')](function(_0x276afb){return _0x276afb;});}return null;};}function removeEntity(_0x1beb61,_0x3dd5ba){return function(_0x41d0cb){if(_0x41d0cb){return _0x41d0cb[_0xf113('0x24')]()[_0xf113('0x23')](function(){_0x1beb61[_0xf113('0x19')](0xcc)[_0xf113('0x18')]();});}};}function handleEntityNotFound(_0x37703d,_0xac40b2){return function(_0x415511){if(!_0x415511){_0x37703d['sendStatus'](0x194);}return _0x415511;};}function handleError(_0x340c78,_0x31e13c){_0x31e13c=_0x31e13c||0x1f4;return function(_0x10e713){logger[_0xf113('0x25')](_0x10e713[_0xf113('0x26')]);if(_0x10e713[_0xf113('0x27')]){delete _0x10e713[_0xf113('0x27')];}_0x340c78[_0xf113('0x19')](_0x31e13c)[_0xf113('0x28')](_0x10e713);};}var utilLicense=require(_0xf113('0x29'));exports[_0xf113('0x2a')]=function(_0x2eb8df,_0x1e254f){var _0x49e898={'raw':!![],'where':{'id':0x1}},_0x3ffe19={};_0x3ffe19[_0xf113('0x2b')]=_['keys'](db['License'][_0xf113('0x2c')]);_0x3ffe19[_0xf113('0x2d')]=_['keys'](_0x2eb8df[_0xf113('0x2d')]);_0x3ffe19[_0xf113('0x2e')]=_[_0xf113('0x2f')](_0x3ffe19[_0xf113('0x2b')],_0x3ffe19[_0xf113('0x2d')]);_0x49e898[_0xf113('0x30')]=_['intersection'](_0x3ffe19[_0xf113('0x2b')],qs['fields'](_0x2eb8df[_0xf113('0x2d')]['fields']));_0x49e898[_0xf113('0x30')]=_0x49e898[_0xf113('0x30')][_0xf113('0x31')]?_0x49e898['attributes']:_0x3ffe19[_0xf113('0x2b')];_0x49e898=_['merge']({},_0x49e898,_0x2eb8df[_0xf113('0x32')]);return utilLicense[_0xf113('0x33')](_0x49e898)['then'](respondWithResult(_0x1e254f,null))[_0xf113('0x34')](handleError(_0x1e254f,null));};exports[_0xf113('0x22')]=function(_0x4f886e,_0x36d2d2){if(_0x4f886e[_0xf113('0x35')]['id']){delete _0x4f886e[_0xf113('0x35')]['id'];}return db[_0xf113('0x36')][_0xf113('0x37')]({'where':{'id':_0x4f886e[_0xf113('0x38')]['id']}})[_0xf113('0x23')](handleEntityNotFound(_0x36d2d2,null))[_0xf113('0x23')](function(_0x5b4966){var _0x48e671=_0x5b4966[_0xf113('0x39')]({'plain':!![]});return utilLicense[_0xf113('0x3a')](_0x48e671,_0x4f886e[_0xf113('0x35')][_0xf113('0x3b')]);})[_0xf113('0x23')](function(_0x2e224e){if(!_0x2e224e['demo']){return saveUpdates(_0x4f886e[_0xf113('0x35')],null);}return _0x2e224e;})[_0xf113('0x23')](respondWithResult(_0x36d2d2,null))[_0xf113('0x34')](handleError(_0x36d2d2,null));};