fix(settings): streamline settings type creation in settingsService and initialization

- Refactored settingsService to use findOrCreate for settings type, improving efficiency and error handling.
- Added initialization for 'account' settings type in initializeSettings, ensuring all necessary settings are created during setup.
This commit is contained in:
Torsten Schulz (local)
2026-03-27 10:43:44 +01:00
parent cf6d72385e
commit 0dd2bce5d1
2 changed files with 8 additions and 6 deletions

View File

@@ -42,12 +42,10 @@ class SettingsService extends BaseService{
return null; return null;
} }
const settingsType = await SettingsType.findOne({ const [settingsType] = await SettingsType.findOrCreate({
where: { name: definition.setting } where: { name: definition.setting },
defaults: { name: definition.setting }
}); });
if (!settingsType) {
throw new Error(`Missing settings type: ${definition.setting}`);
}
const [paramType] = await UserParamType.findOrCreate({ const [paramType] = await UserParamType.findOrCreate({
where: { description }, where: { description },

View File

@@ -17,6 +17,10 @@ const initializeSettings = async () => {
where: { name: 'flirt' }, where: { name: 'flirt' },
defaults: { name: 'flirt' } defaults: { name: 'flirt' }
}); });
await SettingsType.findOrCreate({
where: { name: 'account' },
defaults: { name: 'account' }
});
await SettingsType.findOrCreate({ await SettingsType.findOrCreate({
where: { name: 'languageAssistant' }, where: { name: 'languageAssistant' },
defaults: { name: 'languageAssistant' } defaults: { name: 'languageAssistant' }