Files
SocialPub/PrivaPub/Domain/Statistics/PublicGeo.cs
T

22 lines
861 B
C#
Raw Normal View History

using PrivaPub.Models.Jobs;
namespace PrivaPub.Domain.Statistics
{
public sealed record PublicLocation(string Country, string City, double? Latitude, double? Longitude, string Network, string Cdn);
public static class PublicGeo
{
2026-10-04 11:12:02 +02:00
//a server's place as it is shown publicly: where it was located (country, city, coordinates to 0.1°, network),
//except that a CDN-fronted server shows only its CDN, because the address we reached is the CDN's edge
public static PublicLocation Project(InstanceGeo geo)
{
if (geo == default)
return default;
if (geo.Cdn != default)
return new PublicLocation(default, default, default, default, default, geo.Cdn);
2026-10-04 11:12:02 +02:00
if (geo.Country == default && geo.Latitude == default)
return default;
return new PublicLocation(geo.Country, geo.City, geo.Latitude, geo.Longitude, geo.AsnOrg, default);
}
}
}