diff --git a/Bloxstrap/Integrations/ActivityWatcher.cs b/Bloxstrap/Integrations/ActivityWatcher.cs index ced99cf..3c4696c 100644 --- a/Bloxstrap/Integrations/ActivityWatcher.cs +++ b/Bloxstrap/Integrations/ActivityWatcher.cs @@ -280,17 +280,18 @@ if (GeolocationCache.ContainsKey(ActivityMachineAddress)) return GeolocationCache[ActivityMachineAddress]; - string location, locationCity, locationRegion, locationCountry = ""; - - IPInfoResponse locationInformation; + string location = "", locationCity = "", locationRegion = "", locationCountry = ""; try { - IPInfoResponse locationInformation = await Http.GetJson($"https://ipinfo.io/{ActivityMachineAddress}/json"); + var locationInformation = await Http.GetJson($"https://ipinfo.io/{ActivityMachineAddress}/json"); - locationCity = locationInformation.IP; - locationRegion = locationInformation.Region; - locationCountry = locationInformation.Country; + if (locationInformation is not null) + { + locationCity = locationInformation.IP; + locationRegion = locationInformation.Region; + locationCountry = locationInformation.Country; + } } catch (Exception ex) { diff --git a/Bloxstrap/Models/IPInfoResponse.cs b/Bloxstrap/Models/IPInfoResponse.cs index a0a62c0..6deaf26 100644 --- a/Bloxstrap/Models/IPInfoResponse.cs +++ b/Bloxstrap/Models/IPInfoResponse.cs @@ -2,13 +2,13 @@ namespace Bloxstrap.Models { public class IPInfoResponse { - [JsonPropertyName("city")] - public string? City { get; set; } + [JsonPropertyName("ip")] + public string IP { get; set; } = null!; [JsonPropertyName("country")] - public string? Country { get; set; } + public string Country { get; set; } = null!; [JsonPropertyName("region")] - public string? Region { get; set; } + public string Region { get; set; } = null!; } }