Merge pull request 'patches v1.5.2' (#100) from develop into main

Reviewed-on: #100
This commit is contained in:
Julian Krauser 2025-05-08 06:22:12 +00:00
commit 7db363e3de

View file

@ -57,7 +57,7 @@ export default abstract class SettingHelper {
} }
let processedValue = rawValue; let processedValue = rawValue;
if (typeof settingType.type === "string" && settingType.type.includes("/crypt")) { if (typeof settingType.type === "string" && settingType.type.includes("/crypt") && processedValue != "") {
processedValue = CodingHelper.decrypt(APPLICATION_SECRET, processedValue); processedValue = CodingHelper.decrypt(APPLICATION_SECRET, processedValue);
} }
@ -76,7 +76,7 @@ export default abstract class SettingHelper {
* @param value The value to set * @param value The value to set
*/ */
public static async setSetting<K extends SettingString>(key: K, value: SettingValueMapping[K]): Promise<void> { public static async setSetting<K extends SettingString>(key: K, value: SettingValueMapping[K]): Promise<void> {
if (value === undefined || value === null) { if (value === undefined || value === null || value == "") {
if (key != "mail.password") this.resetSetting(key); if (key != "mail.password") this.resetSetting(key);
return; return;
} }
@ -93,7 +93,7 @@ export default abstract class SettingHelper {
newValue = CodingHelper.encrypt(APPLICATION_SECRET, stringValue); newValue = CodingHelper.encrypt(APPLICATION_SECRET, stringValue);
} }
this.settings[key] = stringValue; this.settings[key] = newValue;
const [topic, settingKey] = key.split(".") as [SettingTopic, string]; const [topic, settingKey] = key.split(".") as [SettingTopic, string];
await SettingCommandHandler.create({ await SettingCommandHandler.create({
@ -265,9 +265,7 @@ export default abstract class SettingHelper {
* @param oldValue The old value * @param oldValue The old value
*/ */
private static notifyListeners(key: SettingString, newValue: any, oldValue: any): void { private static notifyListeners(key: SettingString, newValue: any, oldValue: any): void {
if (!this.listeners.has(key)) return; const callbacks = this.listeners.get(key) ?? [];
const callbacks = this.listeners.get(key)!;
for (const callback of callbacks) { for (const callback of callbacks) {
try { try {
callback(newValue, oldValue); callback(newValue, oldValue);
@ -276,7 +274,7 @@ export default abstract class SettingHelper {
} }
} }
const topicCallbacks = this.topicListeners.get(key.split(".")[0] as SettingTopic)!; const topicCallbacks = this.topicListeners.get(key.split(".")[0] as SettingTopic) ?? [];
for (const callback of topicCallbacks) { for (const callback of topicCallbacks) {
try { try {
callback(); callback();