From d12890f8eb40598b656c084accc7ee58abbfb343 Mon Sep 17 00:00:00 2001 From: Dmitrii Date: Sun, 12 Jul 2026 07:32:28 +0300 Subject: [PATCH] Hotfix mongo`s bugs Signed-off-by: Dmitrii Took 9 minutes --- .../SpMega.Backend/Controllers/v1/WebhookController.cs | 2 +- backend/SpMega.Backend/Persistent/Models/Users/Card.cs | 4 ++-- .../tech/spmega/client/ModMenuIntegration.java | 8 -------- .../git/yawaflua/tech/spmega/client/SPMegaClient.java | 1 - .../spmega/client/ui/service/BackendAuthenticator.java | 2 +- .../java/git/yawaflua/tech/spmega/ConfigManager.java | 10 +--------- src/main/java/git/yawaflua/tech/spmega/ModConfig.java | 5 ++--- 7 files changed, 7 insertions(+), 25 deletions(-) diff --git a/backend/SpMega.Backend/Controllers/v1/WebhookController.cs b/backend/SpMega.Backend/Controllers/v1/WebhookController.cs index 2cbbb51..9c9e227 100644 --- a/backend/SpMega.Backend/Controllers/v1/WebhookController.cs +++ b/backend/SpMega.Backend/Controllers/v1/WebhookController.cs @@ -70,7 +70,7 @@ public class WebhookController( AppDbContext dbContext, ILogger k.ShortId == userShortId); if (user == null) return BadRequest("User not found"); - var cardToUse = user.Cards.FirstOrDefault(c => c.ShortId == cardShortId && c.Id == cardId && c.WebhookConnected); + var cardToUse = user.Cards.FirstOrDefault(c => c.ShortId == cardShortId && c.Id == cardId && c.WebhookConnected == true); if (cardToUse == null) return BadRequest("Card not found"); diff --git a/backend/SpMega.Backend/Persistent/Models/Users/Card.cs b/backend/SpMega.Backend/Persistent/Models/Users/Card.cs index 1094584..9731bdc 100644 --- a/backend/SpMega.Backend/Persistent/Models/Users/Card.cs +++ b/backend/SpMega.Backend/Persistent/Models/Users/Card.cs @@ -9,8 +9,8 @@ public class Card public string Name { get; set; } public string SpworldsID { get; set; } public string Token { get; set; } - public string ShortId { get; set; } = ""; - public bool WebhookConnected { get; set; } = false; + public string? ShortId { get; set; } = ""; + public bool? WebhookConnected { get; set; } = false; public int? Balance { get; set; } = -1; diff --git a/src/client/java/git/yawaflua/tech/spmega/client/ModMenuIntegration.java b/src/client/java/git/yawaflua/tech/spmega/client/ModMenuIntegration.java index b1ad026..6398c41 100644 --- a/src/client/java/git/yawaflua/tech/spmega/client/ModMenuIntegration.java +++ b/src/client/java/git/yawaflua/tech/spmega/client/ModMenuIntegration.java @@ -36,7 +36,6 @@ public class ModMenuIntegration implements ModMenuApi { final GpsHudPosition[] gpsPosition = {current.gpsPosition()}; final GpsHudPosition[] notificationPosition = {current.notificationPosition()}; - final boolean[] telemetryEnabled = {current.telemetryEnabled()}; final int[] telemetryIntervalSeconds = {current.telemetryIntervalSeconds()}; final boolean[] telemetryCollectSystemInfo = {current.telemetryCollectSystemInfo()}; @@ -101,12 +100,6 @@ public class ModMenuIntegration implements ModMenuApi { // Telemetry settings ConfigCategory telemetry = builder.getOrCreateCategory(Text.translatable("category.spmega.telemetry")); - telemetry.addEntry(entryBuilder.startBooleanToggle(Text.translatable("option.spmega.telemetry_enabled"), current.telemetryEnabled()) - .setDefaultValue(ModConfig.DEFAULT_TELEMETRY_ENABLED) - .setTooltip(Text.translatable("tooltip.spmega.telemetry_enabled")) - .setSaveConsumer(newValue -> telemetryEnabled[0] = newValue) - .build()); - telemetry.addEntry(entryBuilder.startIntField(Text.translatable("option.spmega.telemetry_interval"), current.telemetryIntervalSeconds()) .setDefaultValue(ModConfig.DEFAULT_TELEMETRY_INTERVAL_SECONDS) .setMin(10) @@ -134,7 +127,6 @@ public class ModMenuIntegration implements ModMenuApi { gpsEnabledVal, gpsPosition[0], notificationPosition[0], - telemetryEnabled[0], telemetryIntervalSeconds[0], telemetryCollectSystemInfo[0] ); diff --git a/src/client/java/git/yawaflua/tech/spmega/client/SPMegaClient.java b/src/client/java/git/yawaflua/tech/spmega/client/SPMegaClient.java index 44ee160..30128b6 100644 --- a/src/client/java/git/yawaflua/tech/spmega/client/SPMegaClient.java +++ b/src/client/java/git/yawaflua/tech/spmega/client/SPMegaClient.java @@ -120,7 +120,6 @@ public class SPMegaClient implements ClientModInitializer { GpsHudRenderer.instance().isEnabled(), current.gpsPosition(), current.notificationPosition(), - current.telemetryEnabled(), current.telemetryIntervalSeconds(), current.telemetryCollectSystemInfo() ); diff --git a/src/client/java/git/yawaflua/tech/spmega/client/ui/service/BackendAuthenticator.java b/src/client/java/git/yawaflua/tech/spmega/client/ui/service/BackendAuthenticator.java index 0742bd6..e586f51 100644 --- a/src/client/java/git/yawaflua/tech/spmega/client/ui/service/BackendAuthenticator.java +++ b/src/client/java/git/yawaflua/tech/spmega/client/ui/service/BackendAuthenticator.java @@ -141,7 +141,7 @@ public final class BackendAuthenticator { String token = json.get("token").getAsString(); SPMega.setConfig(new ModConfig( config.apiDomain(), token, config.allowBackend(), config.signQuickPayEnabled(), - config.gpsEnabled(), config.gpsPosition(), config.notificationPosition(), config.telemetryEnabled(), + config.gpsEnabled(), config.gpsPosition(), config.notificationPosition(), config.telemetryIntervalSeconds(), config.telemetryCollectSystemInfo())); System.out.println("[SPMEGA] Backend auth successful, saved token."); return true; diff --git a/src/main/java/git/yawaflua/tech/spmega/ConfigManager.java b/src/main/java/git/yawaflua/tech/spmega/ConfigManager.java index 6ceee34..f128f8a 100644 --- a/src/main/java/git/yawaflua/tech/spmega/ConfigManager.java +++ b/src/main/java/git/yawaflua/tech/spmega/ConfigManager.java @@ -74,12 +74,6 @@ public final class ConfigManager { shouldSave = true; } - boolean telemetryEnabled = readBoolean(properties, "telemetry.enabled", defaults.telemetryEnabled()); - String rawTelemetry = properties.getProperty("telemetry.enabled"); - if (rawTelemetry == null || !Boolean.toString(telemetryEnabled).equalsIgnoreCase(rawTelemetry.trim())) { - shouldSave = true; - } - int telemetryIntervalSeconds = readInt(properties, "telemetry.intervalSeconds", defaults.telemetryIntervalSeconds()); String rawInterval = properties.getProperty("telemetry.intervalSeconds"); if (rawInterval == null || !Integer.toString(telemetryIntervalSeconds).equals(rawInterval.trim())) { @@ -93,8 +87,7 @@ public final class ConfigManager { } ModConfig config = new ModConfig(apiDomain, apiToken, allowAccess, signQuickPayEnabled, gpsEnabled, gpsPosition, - notificationPosition, - telemetryEnabled, telemetryIntervalSeconds, telemetryCollectSystemInfo); + notificationPosition, telemetryIntervalSeconds, telemetryCollectSystemInfo); if (shouldSave) { @@ -159,7 +152,6 @@ public final class ConfigManager { properties.setProperty("gps.enabled", Boolean.toString(config.gpsEnabled())); properties.setProperty("gps.position", config.gpsPosition().name()); properties.setProperty("notifications.position", config.notificationPosition().name()); - properties.setProperty("telemetry.enabled", Boolean.toString(config.telemetryEnabled())); properties.setProperty("telemetry.intervalSeconds", Integer.toString(config.telemetryIntervalSeconds())); properties.setProperty("telemetry.collectSystemInfo", Boolean.toString(config.telemetryCollectSystemInfo())); diff --git a/src/main/java/git/yawaflua/tech/spmega/ModConfig.java b/src/main/java/git/yawaflua/tech/spmega/ModConfig.java index faef153..35420fc 100644 --- a/src/main/java/git/yawaflua/tech/spmega/ModConfig.java +++ b/src/main/java/git/yawaflua/tech/spmega/ModConfig.java @@ -2,8 +2,8 @@ package git.yawaflua.tech.spmega; public record ModConfig(String apiDomain, String apiToken, boolean allowBackend, boolean signQuickPayEnabled, boolean gpsEnabled, GpsHudPosition gpsPosition, - GpsHudPosition notificationPosition, - boolean telemetryEnabled, int telemetryIntervalSeconds, boolean telemetryCollectSystemInfo) { + GpsHudPosition notificationPosition, int telemetryIntervalSeconds, + boolean telemetryCollectSystemInfo) { public static final String DEFAULT_API_DOMAIN = "https://spmega.yawaflua.tech"; public static final boolean ALLOW_BACKEND = true; public static final String DEFAULT_API_TOKEN = "-"; @@ -24,7 +24,6 @@ public record ModConfig(String apiDomain, String apiToken, boolean allowBackend, DEFAULT_GPS_ENABLED, DEFAULT_GPS_POSITION, DEFAULT_NOTIFICATION_POSITION, - DEFAULT_TELEMETRY_ENABLED, DEFAULT_TELEMETRY_INTERVAL_SECONDS, DEFAULT_TELEMETRY_COLLECT_SYSTEM_INFO );