Merge remote-tracking branch 'origin/develop' into release-candidate

pull/23339/head
Diego Sampaio 4 years ago
commit d1a8e27943
No known key found for this signature in database
GPG Key ID: E060152B30502562
  1. 6
      ee/server/startup/seatsCap.ts
  2. 9
      package-lock.json
  3. 1
      package.json
  4. 30
      server/startup/migrations/v238.ts

@ -2,7 +2,7 @@ import { Meteor } from 'meteor/meteor';
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
import { callbacks } from '../../../app/callbacks/server';
import { canAddNewUser, getMaxActiveUsers, isEnterprise, onValidateLicenses } from '../../app/license/server/license';
import { canAddNewUser, getMaxActiveUsers, onValidateLicenses } from '../../app/license/server/license';
import { createSeatsLimitBanners, disableDangerBannerDiscardingDismissal, disableWarningBannerDiscardingDismissal, enableDangerBanner, enableWarningBanner } from '../../app/license/server/maxSeatsBanners';
import { validateUserRoles } from '../../app/authorization/server/validateUserRoles';
import { Users } from '../../../app/models/server';
@ -101,9 +101,7 @@ callbacks.add('afterActivateUser', handleMaxSeatsBanners, callbacks.priority.MED
Meteor.startup(() => {
createSeatsLimitBanners();
if (isEnterprise()) {
handleMaxSeatsBanners();
}
handleMaxSeatsBanners();
onValidateLicenses(handleMaxSeatsBanners);
});

9
package-lock.json generated

@ -10903,6 +10903,15 @@
"integrity": "sha512-FTgBI767POY/lKNDNbIzgAX6miIDBs6NTCbdlDb8TrWovHsSvaVIZDlTqym29C6UqhzwcJx4CYr+AlrMywA0cA==",
"dev": true
},
"@types/adm-zip": {
"version": "0.4.34",
"resolved": "https://registry.npmjs.org/@types/adm-zip/-/adm-zip-0.4.34.tgz",
"integrity": "sha512-8ToYLLAYhkRfcmmljrKi22gT2pqu7hGMDtORP1emwIEGmgUTZOsaDjzWFzW5N2frcFRz/50CWt4zA1CxJ73pmQ==",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"@types/agenda": {
"version": "2.0.9",
"resolved": "https://registry.npmjs.org/@types/agenda/-/agenda-2.0.9.tgz",

@ -64,6 +64,7 @@
"@storybook/addon-postcss": "^2.0.0",
"@storybook/addons": "^6.3.6",
"@storybook/react": "^6.3.8",
"@types/adm-zip": "^0.4.34",
"@types/agenda": "^2.0.9",
"@types/bad-words": "^3.0.1",
"@types/bcrypt": "^5.0.0",

@ -1,8 +1,36 @@
import AdmZip from 'adm-zip';
import { AppManager } from '@rocket.chat/apps-engine/server/AppManager';
import { addMigration } from '../../lib/migrations';
import { Apps } from '../../../app/apps/server';
function isPreCompilerRemoval(app: any): boolean {
const fileNames = Object.keys(app.compiled);
return fileNames.some((file) => file.endsWith('$ts'));
}
function repackageAppZip(app: any): Buffer {
const zip = new AdmZip();
const sourceFiles: string[] = [];
Object.entries(app.compiled).forEach(([key, value]) => {
const actualFileName = key.endsWith('$ts') ? key.replace(/\$ts$/, '.js') : key;
sourceFiles.push(actualFileName);
zip.addFile(actualFileName, Buffer.from(value as string, 'utf8'));
});
const zipToRead = new AdmZip(Buffer.from(app.zip, 'base64'));
zipToRead.getEntries().forEach((entry: any) => {
if (!sourceFiles.includes(entry.entryName)) {
zip.addFile(entry.entryName, entry.getData());
}
});
return zip.toBuffer();
}
addMigration({
version: 238,
up() {
@ -11,7 +39,7 @@ addMigration({
const apps = Apps._model.find().fetch();
for (const app of apps) {
const zipFile = Buffer.from(app.zip, 'base64');
const zipFile = isPreCompilerRemoval(app) ? repackageAppZip(app) : Buffer.from(app.zip, 'base64');
Promise.await((Apps._manager as AppManager).update(zipFile, app.permissionsGranted, { loadApp: false }));
Promise.await(Apps._model.update({ id: app.id }, { $unset: { zip: 1, compiled: 1 } }));
}

Loading…
Cancel
Save