chore(geo): drop dead MaxMind fallback + geodb container binding

MaxMind was removed by us; the getGeoForIp closure still carried the
fallback block and depended on a 'geodb' container entry that resolved
to null (no register binding remains). Callers relied solely on the
appwrite-geo HTTP service path, making the fallback unreachable.

Removes:
- Local MaxMind fallback block in getGeoForIp
- 'geodb' dep from the getGeoForIp deps array and closure signature
- Dead 'geodb' container binding in init/resources.php that only
  wrapped a never-registered register->get('geodb')

_APP_GEO_ENDPOINT and _APP_GEO_SECRET already exist in .env and
docker-compose; appwrite container keeps _APP_GEO_SECRET so it can
send it as Bearer to appwrite-geo.
This commit is contained in:
Damodar Lohani
2026-04-23 01:36:37 +00:00
parent 4b7ec5569f
commit cf9db4f89f
2 changed files with 3 additions and 28 deletions
-9
View File
@@ -323,15 +323,6 @@ function getDevice(string $root, string $connection = ''): Device
}
}
$container->set('geodb', function ($register) {
/** @var Utopia\Registry\Registry $register */
try {
return $register->get('geodb');
} catch (\Throwable) {
return;
}
}, ['register']);
$container->set('passwordsDictionary', function ($register) {
/** @var Utopia\Registry\Registry $register */
return $register->get('passwordsDictionary');
+3 -19
View File
@@ -1466,10 +1466,10 @@ return function (Container $container): void {
return $getGeoForIp($ip);
}, ['request', 'getGeoForIp']);
$container->set('getGeoForIp', function (Locale $locale, $geodb) {
$container->set('getGeoForIp', function (Locale $locale) {
$cache = [];
return function (string $ip) use ($locale, $geodb, &$cache): GeoRecord {
return function (string $ip) use ($locale, &$cache): GeoRecord {
if (isset($cache[$ip])) {
return $cache[$ip];
}
@@ -1478,7 +1478,6 @@ return function (Container $container): void {
$geoEndpoint = System::getEnv('_APP_GEO_ENDPOINT', '');
$geoSecret = System::getEnv('_APP_GEO_SECRET', '');
// Try the geo service first (used in Docker/Cloud deployments)
if (!empty($geoEndpoint) && !empty($geoSecret) && filter_var($ip, FILTER_VALIDATE_IP)) {
try {
$client = new Client();
@@ -1497,21 +1496,6 @@ return function (Container $container): void {
}
}
// Fallback to local MaxMind DB for self-hosted deployments
if (empty($record) && $geodb !== null) {
try {
$dbRecord = $geodb->get($ip);
if ($dbRecord) {
$record = [
'countryCode' => $dbRecord['country']['iso_code'] ?? '--',
'continentCode' => $dbRecord['continent']['code'] ?? '--',
];
}
} catch (\Throwable $th) {
Console::warning('Local geodb lookup failed: ' . $th->getMessage());
}
}
$countryCode = $record['countryCode'] ?? '--';
$continentCode = $record['continentCode'] ?? '--';
$unknownCountry = $locale->getText('locale.country.unknown');
@@ -1541,5 +1525,5 @@ return function (Container $container): void {
return $geoRecord;
};
}, ['locale', 'geodb']);
}, ['locale']);
};