From 80d905f5849ae1ec3d4e373c667bd58e69f53d84 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 27 Oct 2020 08:05:56 +0200 Subject: [PATCH] Fixed log structure --- app/controllers/api/account.php | 6 +++--- app/controllers/api/users.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 53bd8bb664..e7f12088df 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -760,11 +760,11 @@ App::get('/v1/account/logs') $record = $geodb->get($log['ip']); if ($record) { - $output[$i]['countryCode'] = \strtolower($record['country']['iso_code']); - $output[$i]['countryCode'] = (isset($countries[$record['country']['iso_code']])) ? $countries[$record['country']['iso_code']] : $locale->getText('locale.country.unknown'); + $output[$i]['countryCode'] = (isset($countries[$record['country']['iso_code']])) ? \strtolower($record['country']['iso_code']) : '--'; + $output[$i]['countryName'] = (isset($countries[$record['country']['iso_code']])) ? $countries[$record['country']['iso_code']] : $locale->getText('locale.country.unknown'); } else { $output[$i]['countryCode'] = '--'; - $output[$i]['countryCode'] = $locale->getText('locale.country.unknown'); + $output[$i]['countryName'] = $locale->getText('locale.country.unknown'); } } diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index a0f8fcebd8..cf84053044 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -286,8 +286,8 @@ App::get('/v1/users/:userId/logs') $record = $geodb->get($log['ip']); - if($record){ - $output[$i]['countryCode'] = \strtolower($record['country']['iso_code']); + if ($record) { + $output[$i]['countryCode'] = (isset($countries[$record['country']['iso_code']])) ? \strtolower($record['country']['iso_code']) : '--'; $output[$i]['countryName'] = (isset($countries[$record['country']['iso_code']])) ? $countries[$record['country']['iso_code']] : $locale->getText('locale.country.unknown'); } else { $output[$i]['countryCode'] = '--';