Hotfix mongo`s bugs
Signed-off-by: Dmitrii <computer@yawaflua.tech> Took 9 minutes
This commit is contained in:
@@ -70,7 +70,7 @@ public class WebhookController( AppDbContext dbContext, ILogger<WebhookControlle
|
|||||||
var user = await dbContext.Users.FirstOrDefaultAsync(k => k.ShortId == userShortId);
|
var user = await dbContext.Users.FirstOrDefaultAsync(k => k.ShortId == userShortId);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
return BadRequest("User not found");
|
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)
|
if (cardToUse == null)
|
||||||
return BadRequest("Card not found");
|
return BadRequest("Card not found");
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ public class Card
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string SpworldsID { get; set; }
|
public string SpworldsID { get; set; }
|
||||||
public string Token { get; set; }
|
public string Token { get; set; }
|
||||||
public string ShortId { get; set; } = "";
|
public string? ShortId { get; set; } = "";
|
||||||
public bool WebhookConnected { get; set; } = false;
|
public bool? WebhookConnected { get; set; } = false;
|
||||||
|
|
||||||
public int? Balance { get; set; } = -1;
|
public int? Balance { get; set; } = -1;
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ public class ModMenuIntegration implements ModMenuApi {
|
|||||||
final GpsHudPosition[] gpsPosition = {current.gpsPosition()};
|
final GpsHudPosition[] gpsPosition = {current.gpsPosition()};
|
||||||
final GpsHudPosition[] notificationPosition = {current.notificationPosition()};
|
final GpsHudPosition[] notificationPosition = {current.notificationPosition()};
|
||||||
|
|
||||||
final boolean[] telemetryEnabled = {current.telemetryEnabled()};
|
|
||||||
final int[] telemetryIntervalSeconds = {current.telemetryIntervalSeconds()};
|
final int[] telemetryIntervalSeconds = {current.telemetryIntervalSeconds()};
|
||||||
final boolean[] telemetryCollectSystemInfo = {current.telemetryCollectSystemInfo()};
|
final boolean[] telemetryCollectSystemInfo = {current.telemetryCollectSystemInfo()};
|
||||||
|
|
||||||
@@ -101,12 +100,6 @@ public class ModMenuIntegration implements ModMenuApi {
|
|||||||
// Telemetry settings
|
// Telemetry settings
|
||||||
ConfigCategory telemetry = builder.getOrCreateCategory(Text.translatable("category.spmega.telemetry"));
|
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())
|
telemetry.addEntry(entryBuilder.startIntField(Text.translatable("option.spmega.telemetry_interval"), current.telemetryIntervalSeconds())
|
||||||
.setDefaultValue(ModConfig.DEFAULT_TELEMETRY_INTERVAL_SECONDS)
|
.setDefaultValue(ModConfig.DEFAULT_TELEMETRY_INTERVAL_SECONDS)
|
||||||
.setMin(10)
|
.setMin(10)
|
||||||
@@ -134,7 +127,6 @@ public class ModMenuIntegration implements ModMenuApi {
|
|||||||
gpsEnabledVal,
|
gpsEnabledVal,
|
||||||
gpsPosition[0],
|
gpsPosition[0],
|
||||||
notificationPosition[0],
|
notificationPosition[0],
|
||||||
telemetryEnabled[0],
|
|
||||||
telemetryIntervalSeconds[0],
|
telemetryIntervalSeconds[0],
|
||||||
telemetryCollectSystemInfo[0]
|
telemetryCollectSystemInfo[0]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -120,7 +120,6 @@ public class SPMegaClient implements ClientModInitializer {
|
|||||||
GpsHudRenderer.instance().isEnabled(),
|
GpsHudRenderer.instance().isEnabled(),
|
||||||
current.gpsPosition(),
|
current.gpsPosition(),
|
||||||
current.notificationPosition(),
|
current.notificationPosition(),
|
||||||
current.telemetryEnabled(),
|
|
||||||
current.telemetryIntervalSeconds(),
|
current.telemetryIntervalSeconds(),
|
||||||
current.telemetryCollectSystemInfo()
|
current.telemetryCollectSystemInfo()
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-1
@@ -141,7 +141,7 @@ public final class BackendAuthenticator {
|
|||||||
String token = json.get("token").getAsString();
|
String token = json.get("token").getAsString();
|
||||||
SPMega.setConfig(new ModConfig(
|
SPMega.setConfig(new ModConfig(
|
||||||
config.apiDomain(), token, config.allowBackend(), config.signQuickPayEnabled(),
|
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()));
|
config.telemetryIntervalSeconds(), config.telemetryCollectSystemInfo()));
|
||||||
System.out.println("[SPMEGA] Backend auth successful, saved token.");
|
System.out.println("[SPMEGA] Backend auth successful, saved token.");
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -74,12 +74,6 @@ public final class ConfigManager {
|
|||||||
shouldSave = true;
|
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());
|
int telemetryIntervalSeconds = readInt(properties, "telemetry.intervalSeconds", defaults.telemetryIntervalSeconds());
|
||||||
String rawInterval = properties.getProperty("telemetry.intervalSeconds");
|
String rawInterval = properties.getProperty("telemetry.intervalSeconds");
|
||||||
if (rawInterval == null || !Integer.toString(telemetryIntervalSeconds).equals(rawInterval.trim())) {
|
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,
|
ModConfig config = new ModConfig(apiDomain, apiToken, allowAccess, signQuickPayEnabled, gpsEnabled, gpsPosition,
|
||||||
notificationPosition,
|
notificationPosition, telemetryIntervalSeconds, telemetryCollectSystemInfo);
|
||||||
telemetryEnabled, telemetryIntervalSeconds, telemetryCollectSystemInfo);
|
|
||||||
|
|
||||||
|
|
||||||
if (shouldSave) {
|
if (shouldSave) {
|
||||||
@@ -159,7 +152,6 @@ public final class ConfigManager {
|
|||||||
properties.setProperty("gps.enabled", Boolean.toString(config.gpsEnabled()));
|
properties.setProperty("gps.enabled", Boolean.toString(config.gpsEnabled()));
|
||||||
properties.setProperty("gps.position", config.gpsPosition().name());
|
properties.setProperty("gps.position", config.gpsPosition().name());
|
||||||
properties.setProperty("notifications.position", config.notificationPosition().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.intervalSeconds", Integer.toString(config.telemetryIntervalSeconds()));
|
||||||
properties.setProperty("telemetry.collectSystemInfo", Boolean.toString(config.telemetryCollectSystemInfo()));
|
properties.setProperty("telemetry.collectSystemInfo", Boolean.toString(config.telemetryCollectSystemInfo()));
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package git.yawaflua.tech.spmega;
|
|||||||
|
|
||||||
public record ModConfig(String apiDomain, String apiToken, boolean allowBackend, boolean signQuickPayEnabled,
|
public record ModConfig(String apiDomain, String apiToken, boolean allowBackend, boolean signQuickPayEnabled,
|
||||||
boolean gpsEnabled, GpsHudPosition gpsPosition,
|
boolean gpsEnabled, GpsHudPosition gpsPosition,
|
||||||
GpsHudPosition notificationPosition,
|
GpsHudPosition notificationPosition, int telemetryIntervalSeconds,
|
||||||
boolean telemetryEnabled, int telemetryIntervalSeconds, boolean telemetryCollectSystemInfo) {
|
boolean telemetryCollectSystemInfo) {
|
||||||
public static final String DEFAULT_API_DOMAIN = "https://spmega.yawaflua.tech";
|
public static final String DEFAULT_API_DOMAIN = "https://spmega.yawaflua.tech";
|
||||||
public static final boolean ALLOW_BACKEND = true;
|
public static final boolean ALLOW_BACKEND = true;
|
||||||
public static final String DEFAULT_API_TOKEN = "-";
|
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_ENABLED,
|
||||||
DEFAULT_GPS_POSITION,
|
DEFAULT_GPS_POSITION,
|
||||||
DEFAULT_NOTIFICATION_POSITION,
|
DEFAULT_NOTIFICATION_POSITION,
|
||||||
DEFAULT_TELEMETRY_ENABLED,
|
|
||||||
DEFAULT_TELEMETRY_INTERVAL_SECONDS,
|
DEFAULT_TELEMETRY_INTERVAL_SECONDS,
|
||||||
DEFAULT_TELEMETRY_COLLECT_SYSTEM_INFO
|
DEFAULT_TELEMETRY_COLLECT_SYSTEM_INFO
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user