Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions app/Http/Resources/Models/Utils/PreComputedPhotoData.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace App\Http\Resources\Models\Utils;

use App\Models\Photo;
use Illuminate\Support\Facades\Auth;
use Spatie\LaravelData\Data;
use Spatie\TypeScriptTransformer\Attributes\TypeScript;

Expand Down Expand Up @@ -40,9 +41,7 @@ public function __construct(Photo $photo, bool $include_exif_data)
}
$this->has_exif = $this->genExifHash($photo) !== '';
$this->has_location = $this->has_location($photo);
$this->latitude = $photo->latitude;
$this->longitude = $photo->longitude;
$this->altitude = $photo->altitude;
$this->set_gps_coordinates($photo);
}

private function has_location(Photo $photo): bool
Expand All @@ -65,4 +64,18 @@ private function genExifHash(Photo $photo): string

return $exif_hash;
}

private function set_gps_coordinates(Photo $photo): void
{
if (request()->configs()->getValueAsBool('gps_coordinate_display') === false) {
return;
}
if (Auth::guest() && request()->configs()->getValueAsBool('gps_coordinate_display_public') === false) {
return;
}

$this->latitude = $photo->latitude;
$this->longitude = $photo->longitude;
$this->altitude = $photo->altitude;
}
}
26 changes: 24 additions & 2 deletions app/Http/Resources/Models/Utils/PreformattedPhotoData.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,33 @@ public function __construct(Photo $photo, bool $include_exif_data, ?SizeVariantR

$this->filesize = $original?->filesize ?? '0';
$this->resolution = $original?->width . ' x ' . $original?->height;

$this->set_gps_coordinates($photo);
$this->set_location($photo);
}

private function set_gps_coordinates(Photo $photo): void
{
if (request()->configs()->getValueAsBool('gps_coordinate_display') === false) {
return;
}
if (Auth::guest() && request()->configs()->getValueAsBool('gps_coordinate_display_public') === false) {
return;
}

$this->latitude = Helpers::decimalToDegreeMinutesSeconds($photo->latitude, true);
$this->longitude = Helpers::decimalToDegreeMinutesSeconds($photo->longitude, false);
$this->altitude = $photo->altitude !== null ? round($photo->altitude, 1) . 'm' : null;
}

$show_location = request()->configs()->getValueAsBool('location_show') && (Auth::check() || request()->configs()->getValueAsBool('location_show_public'));
$this->location = $show_location ? $photo->location : null;
private function set_location(Photo $photo): void
{
if (request()->configs()->getValueAsBool('location_show') === false) {
return;
}
if (Auth::guest() && request()->configs()->getValueAsBool('location_show_public') === false) {
return;
}
$this->location = $photo->location;
}
}
73 changes: 73 additions & 0 deletions database/migrations/2026_01_29_170000_hide_gps_coordinates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

/**
* SPDX-License-Identifier: MIT
* Copyright (c) 2017-2018 Tobias Reich
* Copyright (c) 2018-2026 LycheeOrg.
*/

use Illuminate\Database\Migrations\Migration;

return new class() extends Migration {
public const MOD_MAP = 'Mod Map';
public const BOOL = '0|1';

/**
* @return array<int,array{key:string,value:string,is_secret:bool,cat:string,type_range:string,description:string,order?:int,not_on_docker?:bool,is_expert?:bool,level?:int}>
*/
public function getConfigs(): array
{
return [
[
'key' => 'gps_coordinate_display',
'value' => '1',
'cat' => self::MOD_MAP,
'type_range' => self::BOOL,
'description' => 'Display the GPS coordinates.',
'details' => 'Disabling this hides the Latitude and Longitude information from all users.',
'is_secret' => false,
'is_expert' => false,
'order' => 9,
'not_on_docker' => false,
'level' => 0,
],
[
'key' => 'gps_coordinate_display_public',
'value' => '0',
'cat' => self::MOD_MAP,
'type_range' => self::BOOL,
'description' => 'Allow anonymous users to access the GPS coordinates.',
'details' => 'Disabling this hides the Latitude and Longitude information from anonymous users.',
'is_secret' => false,
'is_expert' => false,
'order' => 10,
'not_on_docker' => false,
'level' => 0,
],
];
}

/**
* Run the migrations.
*
* @codeCoverageIgnore Tested but before CI run...
*/
final public function up(): void
{
DB::table('configs')->insert($this->getConfigs());
DB::table('configs')->where('key', 'location_show')->update(['details' => 'Only the decoded location is impacted by this setting.']);
DB::table('configs')->where('key', 'location_show_public')->update(['details' => 'Only the decoded location is impacted by this setting.']);
}

/**
* Reverse the migrations.
*
* @codeCoverageIgnore Tested but after CI run...
*/
final public function down(): void
{
$keys = collect($this->getConfigs())->map(fn ($v) => $v['key'])->all();
DB::table('configs')->whereIn('key', $keys)->delete();
DB::table('configs')->whereIn('key', ['location_show', 'location_show_public'])->update(['details' => '']);
}
};
8 changes: 6 additions & 2 deletions lang/ar/all_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
'location_decoding_timeout' => 'Timeout for the GPS decoding queries',
'location_show' => 'Show location extracted from GPS coordinates',
'location_show_public' => 'Anonymous users can acess the extracted location from GPS coordinates',
'gps_coordinate_display' => 'Display the GPS coordinates.',
'gps_coordinate_display_public' => 'Allow anonymous users to access the GPS coordinates.',
'rss_enable' => 'Enable RSS feed',
'rss_recent_days' => 'Display the last X days in the RSS feed',
'rss_max_items' => 'Max number of items in the RSS feed',
Expand Down Expand Up @@ -394,8 +396,10 @@
'apply_composer_update' => '',
'location_decoding' => '',
'location_decoding_timeout' => '',
'location_show' => '',
'location_show_public' => '',
'location_show' => 'Only the decoded location is impacted by this setting.',
'location_show_public' => 'Only the decoded location is impacted by this setting.',
'gps_coordinate_display' => 'Disabling this hides the Latitude and Longitude information from all users.',
'gps_coordinate_display_public' => 'Disabling this hides the Latitude and Longitude information from anonymous users.',
'rss_enable' => '',
'rss_recent_days' => '',
'rss_max_items' => '',
Expand Down
2 changes: 2 additions & 0 deletions lang/ar/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
'location_decoding' => 'استخدام فك تشفير موقع GPS',
'location_show' => 'عرض الموقع المستخرج من إحداثيات GPS',
'location_show_public' => 'يمكن للمستخدمين المجهولين الوصول إلى الموقع المستخرج من إحداثيات GPS',
'gps_coordinate_display' => 'Display the GPS coordinates',
'gps_coordinate_display_public' => 'Allow anonymous users to access the GPS coordinates',
],
'cssjs' => [
'header' => 'CSS وJs مخصص',
Expand Down
8 changes: 6 additions & 2 deletions lang/cz/all_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
'location_decoding_timeout' => 'Timeout for the GPS decoding queries',
'location_show' => 'Show location extracted from GPS coordinates',
'location_show_public' => 'Anonymous users can acess the extracted location from GPS coordinates',
'gps_coordinate_display' => 'Display the GPS coordinates.',
'gps_coordinate_display_public' => 'Allow anonymous users to access the GPS coordinates.',
'rss_enable' => 'Enable RSS feed',
'rss_recent_days' => 'Display the last X days in the RSS feed',
'rss_max_items' => 'Max number of items in the RSS feed',
Expand Down Expand Up @@ -394,8 +396,10 @@
'apply_composer_update' => '',
'location_decoding' => '',
'location_decoding_timeout' => '',
'location_show' => '',
'location_show_public' => '',
'location_show' => 'Only the decoded location is impacted by this setting.',
'location_show_public' => 'Only the decoded location is impacted by this setting.',
'gps_coordinate_display' => 'Disabling this hides the Latitude and Longitude information from all users.',
'gps_coordinate_display_public' => 'Disabling this hides the Latitude and Longitude information from anonymous users.',
'rss_enable' => '',
'rss_recent_days' => '',
'rss_max_items' => '',
Expand Down
2 changes: 2 additions & 0 deletions lang/cz/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
'location_decoding' => 'Use GPS location decoding',
'location_show' => 'Show location extracted from GPS coordinates',
'location_show_public' => 'Anonymous users can access the extracted location from GPS coordinates',
'gps_coordinate_display' => 'Display the GPS coordinates',
'gps_coordinate_display_public' => 'Allow anonymous users to access the GPS coordinates',
],
'cssjs' => [
'header' => 'Custom CSS & Js',
Expand Down
8 changes: 6 additions & 2 deletions lang/de/all_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
'location_decoding_timeout' => 'Timeout for the GPS decoding queries',
'location_show' => 'Show location extracted from GPS coordinates',
'location_show_public' => 'Anonymous users can acess the extracted location from GPS coordinates',
'gps_coordinate_display' => 'Display the GPS coordinates.',
'gps_coordinate_display_public' => 'Allow anonymous users to access the GPS coordinates.',
'rss_enable' => 'Enable RSS feed',
'rss_recent_days' => 'Display the last X days in the RSS feed',
'rss_max_items' => 'Max number of items in the RSS feed',
Expand Down Expand Up @@ -392,8 +394,10 @@
'apply_composer_update' => '',
'location_decoding' => '',
'location_decoding_timeout' => '',
'location_show' => '',
'location_show_public' => '',
'location_show' => 'Only the decoded location is impacted by this setting.',
'location_show_public' => 'Only the decoded location is impacted by this setting.',
'gps_coordinate_display' => 'Disabling this hides the Latitude and Longitude information from all users.',
'gps_coordinate_display_public' => 'Disabling this hides the Latitude and Longitude information from anonymous users.',
'rss_enable' => '',
'rss_recent_days' => '',
'rss_max_items' => '',
Expand Down
2 changes: 2 additions & 0 deletions lang/de/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
'location_decoding' => 'GPS-Standortdecodierung verwenden',
'location_show' => 'Aus GPS-Koordinaten extrahierten Standort anzeigen',
'location_show_public' => 'Anonyme Nutzer können auf den aus den GPS-Koordinaten extrahierten Standort zugreifen',
'gps_coordinate_display' => 'Display the GPS coordinates',
'gps_coordinate_display_public' => 'Allow anonymous users to access the GPS coordinates',
],
'cssjs' => [
'header' => 'Benutzerdefinierte CSS & JS',
Expand Down
8 changes: 6 additions & 2 deletions lang/el/all_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
'location_decoding_timeout' => 'Timeout for the GPS decoding queries',
'location_show' => 'Show location extracted from GPS coordinates',
'location_show_public' => 'Anonymous users can acess the extracted location from GPS coordinates',
'gps_coordinate_display' => 'Display the GPS coordinates.',
'gps_coordinate_display_public' => 'Allow anonymous users to access the GPS coordinates.',
'rss_enable' => 'Enable RSS feed',
'rss_recent_days' => 'Display the last X days in the RSS feed',
'rss_max_items' => 'Max number of items in the RSS feed',
Expand Down Expand Up @@ -394,8 +396,10 @@
'apply_composer_update' => '',
'location_decoding' => '',
'location_decoding_timeout' => '',
'location_show' => '',
'location_show_public' => '',
'location_show' => 'Only the decoded location is impacted by this setting.',
'location_show_public' => 'Only the decoded location is impacted by this setting.',
'gps_coordinate_display' => 'Disabling this hides the Latitude and Longitude information from all users.',
'gps_coordinate_display_public' => 'Disabling this hides the Latitude and Longitude information from anonymous users.',
'rss_enable' => '',
'rss_recent_days' => '',
'rss_max_items' => '',
Expand Down
2 changes: 2 additions & 0 deletions lang/el/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
'location_decoding' => 'Use GPS location decoding',
'location_show' => 'Show location extracted from GPS coordinates',
'location_show_public' => 'Anonymous users can access the extracted location from GPS coordinates',
'gps_coordinate_display' => 'Display the GPS coordinates',
'gps_coordinate_display_public' => 'Allow anonymous users to access the GPS coordinates',
],
'cssjs' => [
'header' => 'Custom CSS & Js',
Expand Down
8 changes: 6 additions & 2 deletions lang/en/all_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
'location_decoding_timeout' => 'Timeout for the GPS decoding queries',
'location_show' => 'Show location extracted from GPS coordinates',
'location_show_public' => 'Anonymous users can acess the extracted location from GPS coordinates',
'gps_coordinate_display' => 'Display the GPS coordinates.',
'gps_coordinate_display_public' => 'Allow anonymous users to access the GPS coordinates.',
'rss_enable' => 'Enable RSS feed',
'rss_recent_days' => 'Display the last X days in the RSS feed',
'rss_max_items' => 'Max number of items in the RSS feed',
Expand Down Expand Up @@ -394,8 +396,10 @@
'apply_composer_update' => '',
'location_decoding' => '',
'location_decoding_timeout' => '',
'location_show' => '',
'location_show_public' => '',
'location_show' => 'Only the decoded location is impacted by this setting.',
'location_show_public' => 'Only the decoded location is impacted by this setting.',
'gps_coordinate_display' => 'Disabling this hides the Latitude and Longitude information from all users.',
'gps_coordinate_display_public' => 'Disabling this hides the Latitude and Longitude information from anonymous users.',
'rss_enable' => '',
'rss_recent_days' => '',
'rss_max_items' => '',
Expand Down
2 changes: 2 additions & 0 deletions lang/en/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
'location_decoding' => 'Use GPS location decoding',
'location_show' => 'Show location extracted from GPS coordinates',
'location_show_public' => 'Anonymous users can access the extracted location from GPS coordinates',
'gps_coordinate_display' => 'Display the GPS coordinates',
'gps_coordinate_display_public' => 'Allow anonymous users to access the GPS coordinates',
],
'cssjs' => [
'header' => 'Custom CSS & Js',
Expand Down
8 changes: 6 additions & 2 deletions lang/es/all_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
'location_decoding_timeout' => 'Timeout for the GPS decoding queries',
'location_show' => 'Show location extracted from GPS coordinates',
'location_show_public' => 'Anonymous users can acess the extracted location from GPS coordinates',
'gps_coordinate_display' => 'Display the GPS coordinates.',
'gps_coordinate_display_public' => 'Allow anonymous users to access the GPS coordinates.',
'rss_enable' => 'Enable RSS feed',
'rss_recent_days' => 'Display the last X days in the RSS feed',
'rss_max_items' => 'Max number of items in the RSS feed',
Expand Down Expand Up @@ -394,8 +396,10 @@
'apply_composer_update' => '',
'location_decoding' => '',
'location_decoding_timeout' => '',
'location_show' => '',
'location_show_public' => '',
'location_show' => 'Only the decoded location is impacted by this setting.',
'location_show_public' => 'Only the decoded location is impacted by this setting.',
'gps_coordinate_display' => 'Disabling this hides the Latitude and Longitude information from all users.',
'gps_coordinate_display_public' => 'Disabling this hides the Latitude and Longitude information from anonymous users.',
'rss_enable' => '',
'rss_recent_days' => '',
'rss_max_items' => '',
Expand Down
2 changes: 2 additions & 0 deletions lang/es/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
'location_decoding' => 'Utilice la decodificación de ubicación GPS',
'location_show' => 'Mostrar ubicación extraída de coordenadas GPS',
'location_show_public' => 'Los usuarios anónimos pueden acceder a la ubicación extraída de las coordenadas GPS',
'gps_coordinate_display' => 'Display the GPS coordinates',
'gps_coordinate_display_public' => 'Allow anonymous users to access the GPS coordinates',
],
'cssjs' => [
'header' => 'CSS y JavaScript personalizados',
Expand Down
8 changes: 6 additions & 2 deletions lang/fa/all_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
'location_decoding_timeout' => 'Timeout for the GPS decoding queries',
'location_show' => 'Show location extracted from GPS coordinates',
'location_show_public' => 'Anonymous users can acess the extracted location from GPS coordinates',
'gps_coordinate_display' => 'Display the GPS coordinates.',
'gps_coordinate_display_public' => 'Allow anonymous users to access the GPS coordinates.',
'rss_enable' => 'Enable RSS feed',
'rss_recent_days' => 'Display the last X days in the RSS feed',
'rss_max_items' => 'Max number of items in the RSS feed',
Expand Down Expand Up @@ -394,8 +396,10 @@
'apply_composer_update' => '',
'location_decoding' => '',
'location_decoding_timeout' => '',
'location_show' => '',
'location_show_public' => '',
'location_show' => 'Only the decoded location is impacted by this setting.',
'location_show_public' => 'Only the decoded location is impacted by this setting.',
'gps_coordinate_display' => 'Disabling this hides the Latitude and Longitude information from all users.',
'gps_coordinate_display_public' => 'Disabling this hides the Latitude and Longitude information from anonymous users.',
'rss_enable' => '',
'rss_recent_days' => '',
'rss_max_items' => '',
Expand Down
4 changes: 2 additions & 2 deletions lang/fa/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
'map_include_subalbums' => 'نمایش تصاویر زیرآلبوم‌ها روی نقشه',
'location_decoding' => 'استفاده از رمزگشایی موقعیت GPS',
'location_show' => 'نمایش موقعیت استخراج شده از مختصات GPS',
'location_show_public' => 'کاربران ناشناس می‌توانند به موقعیت استخراج شده از مختصات GPS دسترسی داشته باشند',
],
'location_show_public' => 'کاربران ناشناس می‌توانند به موقعیت استخراج شده از مختصات GPS دسترسی داشته باشند', 'gps_coordinate_display' => 'Display the GPS coordinates',
'gps_coordinate_display_public' => 'Allow anonymous users to access the GPS coordinates', ],
'cssjs' => [
'header' => 'CSS و JS سفارشی',
'change_css' => 'تغییر CSS',
Expand Down
8 changes: 6 additions & 2 deletions lang/fr/all_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@
'apply_composer_update' => '',
'location_decoding' => '',
'location_decoding_timeout' => '',
'location_show' => '',
'location_show_public' => '',
'location_show' => 'Only the decoded location is impacted by this setting.',
'location_show_public' => 'Only the decoded location is impacted by this setting.',
'gps_coordinate_display' => 'Disabling this hides the Latitude and Longitude information from all users.',
'gps_coordinate_display_public' => 'Disabling this hides the Latitude and Longitude information from anonymous users.',
'rss_enable' => '',
'rss_recent_days' => '',
'rss_max_items' => '',
Expand Down Expand Up @@ -394,6 +396,8 @@
'location_decoding_timeout' => 'Délai d’attente pour les requêtes de décodage GPS',
'location_show' => 'Afficher la localisation extraite des coordonnées GPS',
'location_show_public' => 'Permettre aux utilisateurs anonymes d’accéder à la localisation extraite',
'gps_coordinate_display' => 'Display the GPS coordinates.',
'gps_coordinate_display_public' => 'Allow anonymous users to access the GPS coordinates.',
'rss_enable' => 'Activer le flux RSS',
'rss_recent_days' => 'Afficher les X derniers jours dans le flux RSS',
'rss_max_items' => 'Nombre maximal d’éléments dans le flux RSS',
Expand Down
2 changes: 2 additions & 0 deletions lang/fr/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
'location_decoding' => 'Utiliser le décodage de position GPS',
'location_show' => 'Afficher la localisation extraite des coordonnées GPS',
'location_show_public' => 'Les utilisateurs anonymes peuvent accéder à la localisation extraite',
'gps_coordinate_display' => 'Display the GPS coordinates',
'gps_coordinate_display_public' => 'Allow anonymous users to access the GPS coordinates',
],
'cssjs' => [
'header' => 'CSS & JS personnalisés',
Expand Down
Loading
Loading