Build error fix and added back ip property

This commit is contained in:
BuildTools 2024-04-15 00:43:44 +01:00
parent 868ee2a4ff
commit 38edb68574
2 changed files with 12 additions and 11 deletions

View File

@ -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<IPInfoResponse>($"https://ipinfo.io/{ActivityMachineAddress}/json");
var locationInformation = await Http.GetJson<IPInfoResponse>($"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)
{

View File

@ -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!;
}
}