Skip to content
Snippets Groups Projects
Unverified Commit b7089483 authored by felipe-menelau's avatar felipe-menelau Committed by GitHub
Browse files

[NEW] Use setting to determine if initial general channel is needed (#25441)


* feat: adds FORCE_CREATE_GENERAL flag that creates general channel even when setup wizard is not pending

* fix: moves FORCE_CREATE_GENERAL to hidden setting

* Change flow

* Remove import

* Fix findOne

* Migration to avoid general re-creation

Co-authored-by: default avatarDiego Sampaio <chinello@gmail.com>
parent 216301c9
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,11 @@ settingsRegistry.add('uniqueID', process.env.DEPLOYMENT_ID || Random.id(), {
public: true,
});
settingsRegistry.add('Initial_Channel_Created', false, {
type: 'boolean',
hidden: true,
});
// When you define a setting and want to add a description, you don't need to automatically define the i18nDescription
// if you add a node to the i18n.json with the same setting name but with `_Description` it will automatically work.
......
......@@ -12,10 +12,15 @@ import { Settings } from '../../app/models/server/raw';
import { validateEmail } from '../../lib/emailValidator';
Meteor.startup(async function () {
if (settings.get('Show_Setup_Wizard') === 'pending' && !Rooms.findOneById('GENERAL')) {
Rooms.createWithIdTypeAndName('GENERAL', 'c', 'general', {
default: true,
});
if (!settings.get('Initial_Channel_Created')) {
const exists = Rooms.findOneById('GENERAL', { fields: { _id: 1 } });
if (!exists) {
Rooms.createWithIdTypeAndName('GENERAL', 'c', 'general', {
default: true,
});
}
Settings.updateValueById('Initial_Channel_Created', true);
}
if (!Users.findOneById('rocket.cat')) {
......
......@@ -87,4 +87,5 @@ import './v260';
import './v261';
import './v262';
import './v263';
import './v264';
import './xrun';
import { addMigration } from '../../lib/migrations';
import { Settings } from '../../../app/models/server/raw';
addMigration({
version: 264,
async up() {
// in case server is being updated, we check setup wizard status to determine if should still create the initial channel
const setupWizard = await Settings.getValueById('Show_Setup_Wizard');
if (setupWizard === 'pending') {
// if still pending for some reason, we need to create the initial channel, so keep the setting as false
return;
}
// if the setup wizard is not pending anymore, we assume initial channel was already created once
await Settings.updateValueById('Initial_Channel_Created', true);
},
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment