Add geolocation data retrieval and update server registration with geolocation information
This commit is contained in:
@@ -4,7 +4,10 @@ import 'package:waylume_server/core/utils.dart';
|
||||
|
||||
class ServerService {
|
||||
static Future<void> registerServer() async {
|
||||
String ip = "${await getWanIp()}:${fromEnivronment("EXTERNAL_PORT") ?? "3000"}";
|
||||
|
||||
GeolocationData geolocationData = await getGeolocationData();
|
||||
|
||||
String ip = "${geolocationData.ip}:${fromEnivronment("EXTERNAL_PORT") ?? "3000"}";
|
||||
|
||||
var existsCheck = await SUPABASE_CLIENT
|
||||
.from("waylume_servers")
|
||||
@@ -19,6 +22,10 @@ class ServerService {
|
||||
"id": fromEnivronment('SERVER_ID')!,
|
||||
"last_heartbeat": DateTime.now().toUtc().toIso8601String(),
|
||||
"host_ip": ip,
|
||||
"geolocation": {
|
||||
"country_code": geolocationData.continentCode,
|
||||
"city": geolocationData.city,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user