Built motion from commit (unavailable).|2.5.13
[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 _0xfc76=['body','find','params','then','get','checkLicense','demo','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','sendStatus','status','offset','limit','set','Content-Range','apply','reject','update','destroy','error','stack','name','send','index','model','License','rawAttributes','query','keys','filters','intersection','fields','attributes','length','merge','catch'];(function(_0xce459f,_0x360bee){var _0x30c9d8=function(_0x1f3891){while(--_0x1f3891){_0xce459f['push'](_0xce459f['shift']());}};_0x30c9d8(++_0x360bee);}(_0xfc76,0xb5));var _0x6fc7=function(_0x361629,_0xc8f64f){_0x361629=_0x361629-0x0;var _0x3d5142=_0xfc76[_0x361629];return _0x3d5142;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x6fc7('0x0'));var rimraf=require(_0x6fc7('0x1'));var zipdir=require(_0x6fc7('0x2'));var jsonpatch=require(_0x6fc7('0x3'));var rp=require(_0x6fc7('0x4'));var moment=require('moment');var BPromise=require(_0x6fc7('0x5'));var Mustache=require(_0x6fc7('0x6'));var util=require('util');var path=require(_0x6fc7('0x7'));var sox=require('sox');var csv=require(_0x6fc7('0x8'));var ejs=require(_0x6fc7('0x9'));var fs=require('fs');var _=require(_0x6fc7('0xa'));var squel=require('squel');var crypto=require(_0x6fc7('0xb'));var jsforce=require(_0x6fc7('0xc'));var deskjs=require(_0x6fc7('0xd'));var toCsv=require(_0x6fc7('0x8'));var querystring=require(_0x6fc7('0xe'));var Papa=require(_0x6fc7('0xf'));var Redis=require('ioredis');var authService=require(_0x6fc7('0x10'));var qs=require(_0x6fc7('0x11'));var as=require(_0x6fc7('0x12'));var hardwareService=require(_0x6fc7('0x13'));var logger=require(_0x6fc7('0x14'))(_0x6fc7('0x15'));var utils=require('../../config/utils');var config=require(_0x6fc7('0x16'));var licenseUtil=require(_0x6fc7('0x17'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x433adc,_0x2c32b8){_0x2c32b8=_0x2c32b8||0xcc;return function(_0x5f438d){if(_0x5f438d){return _0x433adc[_0x6fc7('0x18')](_0x2c32b8);}return _0x433adc[_0x6fc7('0x19')](_0x2c32b8)['end']();};}function respondWithResult(_0x44d8e0,_0x3c107f){_0x3c107f=_0x3c107f||0xc8;return function(_0x10a482){if(_0x10a482){return _0x44d8e0['status'](_0x3c107f)['json'](_0x10a482);}};}function respondWithFilteredResult(_0xbb4a3e,_0x45d585){return function(_0x499bcc){if(_0x499bcc){var _0x2b0122=_0x499bcc['count'],_0x15e4db=_0x45d585[_0x6fc7('0x1a')],_0x124cd6=_0x45d585[_0x6fc7('0x1a')]+_0x45d585[_0x6fc7('0x1b')],_0x41269a;if(_0x124cd6>=_0x2b0122){_0x124cd6=_0x2b0122;_0x41269a=0xc8;}else{_0x41269a=0xce;}_0xbb4a3e[_0x6fc7('0x19')](_0x41269a);return _0xbb4a3e[_0x6fc7('0x1c')](_0x6fc7('0x1d'),_0x15e4db+'-'+_0x124cd6+'/'+_0x2b0122)['json'](_0x499bcc);}return null;};}function patchUpdates(_0x109c84){return function(_0x124893){try{jsonpatch[_0x6fc7('0x1e')](_0x124893,_0x109c84,!![]);}catch(_0x3bd771){return BPromise[_0x6fc7('0x1f')](_0x3bd771);}return _0x124893['save']();};}function saveUpdates(_0x277f9e,_0x2427a){return function(_0x5a6798){if(_0x5a6798){return _0x5a6798[_0x6fc7('0x20')](_0x277f9e)['then'](function(_0x453bae){return _0x453bae;});}return null;};}function removeEntity(_0x4f583c,_0x11b359){return function(_0xdb5974){if(_0xdb5974){return _0xdb5974[_0x6fc7('0x21')]()['then'](function(){_0x4f583c[_0x6fc7('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2dd21a,_0xdd4827){return function(_0x2229a1){if(!_0x2229a1){_0x2dd21a[_0x6fc7('0x18')](0x194);}return _0x2229a1;};}function handleError(_0x1ca0eb,_0x222b53){_0x222b53=_0x222b53||0x1f4;return function(_0x190680){logger[_0x6fc7('0x22')](_0x190680[_0x6fc7('0x23')]);if(_0x190680[_0x6fc7('0x24')]){delete _0x190680[_0x6fc7('0x24')];}_0x1ca0eb[_0x6fc7('0x19')](_0x222b53)[_0x6fc7('0x25')](_0x190680);};}var utilLicense=require(_0x6fc7('0x17'));exports[_0x6fc7('0x26')]=function(_0x5880cc,_0x266af9){var _0x3053b1={'raw':!![],'where':{'id':0x1}},_0x168c87={};_0x168c87[_0x6fc7('0x27')]=_['keys'](db[_0x6fc7('0x28')][_0x6fc7('0x29')]);_0x168c87[_0x6fc7('0x2a')]=_[_0x6fc7('0x2b')](_0x5880cc[_0x6fc7('0x2a')]);_0x168c87[_0x6fc7('0x2c')]=_[_0x6fc7('0x2d')](_0x168c87[_0x6fc7('0x27')],_0x168c87['query']);_0x3053b1['attributes']=_[_0x6fc7('0x2d')](_0x168c87[_0x6fc7('0x27')],qs[_0x6fc7('0x2e')](_0x5880cc[_0x6fc7('0x2a')][_0x6fc7('0x2e')]));_0x3053b1[_0x6fc7('0x2f')]=_0x3053b1['attributes'][_0x6fc7('0x30')]?_0x3053b1[_0x6fc7('0x2f')]:_0x168c87[_0x6fc7('0x27')];_0x3053b1=_[_0x6fc7('0x31')]({},_0x3053b1,_0x5880cc['options']);return utilLicense['getLicense'](_0x3053b1)['then'](respondWithResult(_0x266af9,null))[_0x6fc7('0x32')](handleError(_0x266af9,null));};exports[_0x6fc7('0x20')]=function(_0x2fd248,_0x4673d9){if(_0x2fd248[_0x6fc7('0x33')]['id']){delete _0x2fd248[_0x6fc7('0x33')]['id'];}return db[_0x6fc7('0x28')][_0x6fc7('0x34')]({'where':{'id':_0x2fd248[_0x6fc7('0x35')]['id']}})['then'](handleEntityNotFound(_0x4673d9,null))[_0x6fc7('0x36')](function(_0x549b27){var _0x40ee9c=_0x549b27[_0x6fc7('0x37')]({'plain':!![]});return utilLicense[_0x6fc7('0x38')](_0x40ee9c,_0x2fd248[_0x6fc7('0x33')]['key']);})[_0x6fc7('0x36')](function(_0x3245a8){if(!_0x3245a8[_0x6fc7('0x39')]){return saveUpdates(_0x2fd248[_0x6fc7('0x33')],null);}return _0x3245a8;})['then'](respondWithResult(_0x4673d9,null))[_0x6fc7('0x32')](handleError(_0x4673d9,null));};