Update Privacy Settings, add support for Mastodon indexable search flag

This commit is contained in:
Daniel Supernault 2023-08-24 23:31:33 -06:00
parent a3696dac95
commit fc24630eba
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
5 changed files with 64 additions and 15 deletions

View file

@ -20,13 +20,13 @@ trait PrivacySettings
public function privacy() public function privacy()
{ {
$user = Auth::user(); $user = Auth::user();
$settings = $user->settings; $settings = $user->settings;
$profile = $user->profile; $profile = $user->profile;
$is_private = $profile->is_private; $is_private = $profile->is_private;
$settings['is_private'] = (bool) $is_private; $settings['is_private'] = (bool) $is_private;
return view('settings.privacy', compact('settings', 'profile')); return view('settings.privacy', compact('settings', 'profile'));
} }
public function privacyStore(Request $request) public function privacyStore(Request $request)
@ -39,11 +39,13 @@ trait PrivacySettings
'public_dm', 'public_dm',
'show_profile_follower_count', 'show_profile_follower_count',
'show_profile_following_count', 'show_profile_following_count',
'indexable',
'show_atom', 'show_atom',
]; ];
$profile->is_suggestable = $request->input('is_suggestable') == 'on'; $profile->indexable = $request->input('indexable') == 'on';
$profile->save(); $profile->is_suggestable = $request->input('is_suggestable') == 'on';
$profile->save();
foreach ($fields as $field) { foreach ($fields as $field) {
$form = $request->input($field); $form = $request->input($field);
@ -70,6 +72,8 @@ trait PrivacySettings
} else { } else {
$settings->{$field} = false; $settings->{$field} = false;
} }
} elseif ($field == 'indexable') {
} else { } else {
if ($form == 'on') { if ($form == 'on') {
$settings->{$field} = true; $settings->{$field} = true;

View file

@ -16,6 +16,8 @@ class ProfileTransformer extends Fractal\TransformerAbstract
'https://www.w3.org/ns/activitystreams', 'https://www.w3.org/ns/activitystreams',
[ [
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers', 'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
'pixelfed' => 'http://pixelfed.org/ns#',
'schema' => 'http://schema.org/',
'alsoKnownAs' => [ 'alsoKnownAs' => [
'@id' => 'as:alsoKnownAs', '@id' => 'as:alsoKnownAs',
'@type' => '@id' '@type' => '@id'
@ -23,6 +25,10 @@ class ProfileTransformer extends Fractal\TransformerAbstract
'movedTo' => [ 'movedTo' => [
'@id' => 'as:movedTo', '@id' => 'as:movedTo',
'@type' => '@id' '@type' => '@id'
],
'indexable' => [
'@id' => 'pixelfed:indexable',
'@type' => 'schema:Boolean'
] ]
], ],
], ],
@ -37,6 +43,7 @@ class ProfileTransformer extends Fractal\TransformerAbstract
'summary' => $profile->bio, 'summary' => $profile->bio,
'url' => $profile->url(), 'url' => $profile->url(),
'manuallyApprovesFollowers' => (bool) $profile->is_private, 'manuallyApprovesFollowers' => (bool) $profile->is_private,
'indexable' => (bool) $profile->indexable,
'publicKey' => [ 'publicKey' => [
'id' => $profile->permalink().'#main-key', 'id' => $profile->permalink().'#main-key',
'owner' => $profile->permalink(), 'owner' => $profile->permalink(),

View file

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('profiles', function (Blueprint $table) {
$table->boolean('indexable')->default(false)->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('profiles', function (Blueprint $table) {
$table->dropColumn('indexable');
});
}
};

View file

@ -72,6 +72,8 @@
@media only screen and (min-width: 768px) { @media only screen and (min-width: 768px) {
border-right: 1px solid #dee2e6 !important border-right: 1px solid #dee2e6 !important
} }
height: 100%;
flex-grow: 1;
} }
</style> </style>
@endpush @endpush

View file

@ -28,9 +28,17 @@
<div class="form-check pb-3"> <div class="form-check pb-3">
<input class="form-check-input" type="checkbox" name="crawlable" id="crawlable" {{!$settings->crawlable ? 'checked=""':''}} {{$settings->is_private ? 'disabled=""':''}}> <input class="form-check-input" type="checkbox" name="crawlable" id="crawlable" {{!$settings->crawlable ? 'checked=""':''}} {{$settings->is_private ? 'disabled=""':''}}>
<label class="form-check-label font-weight-bold" for="crawlable"> <label class="form-check-label font-weight-bold" for="crawlable">
{{__('Opt-out of search engine indexing')}} {{__('Disable Search Engine indexing')}}
</label> </label>
<p class="text-muted small help-text">When your account is visible to search engines, your information can be crawled and stored by search engines.</p> <p class="text-muted small help-text">When your account is visible to search engines, your information can be crawled and stored by search engines. {!! $settings->is_private ? '<strong>Not available when your account is private</strong>' : ''!!}</p>
</div>
<div class="form-check pb-3">
<input class="form-check-input" type="checkbox" name="indexable" id="indexable" {{$profile->indexable ? 'checked=""':''}} {{$settings->is_private ? 'disabled=""':''}}>
<label class="form-check-label font-weight-bold" for="indexable">
{{__('Include public posts in search results')}}
</label>
<p class="text-muted small help-text">Your public posts may appear in search results on Pixelfed and Mastodon. People who have interacted with your posts may be able to search them regardless. {!! $settings->is_private ? '<strong>Not available when your account is private</strong>' : ''!!}</p>
</div> </div>
@ -39,7 +47,7 @@
<label class="form-check-label font-weight-bold" for="is_suggestable"> <label class="form-check-label font-weight-bold" for="is_suggestable">
{{__('Show on Directory')}} {{__('Show on Directory')}}
</label> </label>
<p class="text-muted small help-text">When this option is enabled, your profile is included in the Directory. Only public profiles are eligible.</p> <p class="text-muted small help-text">When this option is enabled, your profile is included in the Directory. Only public profiles are eligible. {!! $settings->is_private ? '<strong>Not available when your account is private</strong>' : ''!!}</p>
</div> </div>
<div class="form-check pb-3"> <div class="form-check pb-3">
@ -97,10 +105,10 @@
<p class="text-muted small help-text mb-0">Enable your profile atom feed. Only public profiles are eligible.</p> <p class="text-muted small help-text mb-0">Enable your profile atom feed. Only public profiles are eligible.</p>
@if($settings->show_atom) @if($settings->show_atom)
<p class="small"> <p class="small">
<a href="{{$profile->permalink('.atom')}}" class="text-success font-weight-bold small" target="_blank"> <a href="{{$profile->permalink('.atom')}}" class="text-success font-weight-bold small" target="_blank">
{{ $profile->permalink('.atom') }} {{ $profile->permalink('.atom') }}
<i class="far fa-external-link ml-1 text-muted" style="opacity: 0.5"></i> <i class="far fa-external-link ml-1 text-muted" style="opacity: 0.5"></i>
</a> </a>
</p> </p>
@endif @endif
</div> </div>