Skip to content

Commit

Permalink
Update Privacy Settings, add support for Mastodon indexable search flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dansup committed Aug 25, 2023
1 parent a3696da commit fc24630
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 15 deletions.
20 changes: 12 additions & 8 deletions app/Http/Controllers/Settings/PrivacySettings.php
Expand Up @@ -20,13 +20,13 @@ trait PrivacySettings

public function privacy()
{
$user = Auth::user();
$settings = $user->settings;
$profile = $user->profile;
$is_private = $profile->is_private;
$settings['is_private'] = (bool) $is_private;
$user = Auth::user();
$settings = $user->settings;
$profile = $user->profile;
$is_private = $profile->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)
Expand All @@ -39,11 +39,13 @@ public function privacyStore(Request $request)
'public_dm',
'show_profile_follower_count',
'show_profile_following_count',
'indexable',
'show_atom',
];

$profile->is_suggestable = $request->input('is_suggestable') == 'on';
$profile->save();
$profile->indexable = $request->input('indexable') == 'on';
$profile->is_suggestable = $request->input('is_suggestable') == 'on';
$profile->save();

foreach ($fields as $field) {
$form = $request->input($field);
Expand All @@ -70,6 +72,8 @@ public function privacyStore(Request $request)
} else {
$settings->{$field} = false;
}
} elseif ($field == 'indexable') {

} else {
if ($form == 'on') {
$settings->{$field} = true;
Expand Down
7 changes: 7 additions & 0 deletions app/Transformer/ActivityPub/ProfileTransformer.php
Expand Up @@ -16,13 +16,19 @@ public function transform(Profile $profile)
'https://www.w3.org/ns/activitystreams',
[
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
'pixelfed' => 'http://pixelfed.org/ns#',
'schema' => 'http://schema.org/',
'alsoKnownAs' => [
'@id' => 'as:alsoKnownAs',
'@type' => '@id'
],
'movedTo' => [
'@id' => 'as:movedTo',
'@type' => '@id'
],
'indexable' => [
'@id' => 'pixelfed:indexable',
'@type' => 'schema:Boolean'
]
],
],
Expand All @@ -37,6 +43,7 @@ public function transform(Profile $profile)
'summary' => $profile->bio,
'url' => $profile->url(),
'manuallyApprovesFollowers' => (bool) $profile->is_private,
'indexable' => (bool) $profile->indexable,
'publicKey' => [
'id' => $profile->permalink().'#main-key',
'owner' => $profile->permalink(),
Expand Down
@@ -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');
});
}
};
2 changes: 2 additions & 0 deletions resources/views/settings/partial/sidebar.blade.php
Expand Up @@ -72,6 +72,8 @@
@media only screen and (min-width: 768px) {
border-right: 1px solid #dee2e6 !important
}
height: 100%;
flex-grow: 1;
}
</style>
@endpush
22 changes: 15 additions & 7 deletions resources/views/settings/privacy.blade.php
Expand Up @@ -28,9 +28,17 @@
<div class="form-check pb-3">
<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">
{{__('Opt-out of search engine indexing')}}
{{__('Disable Search Engine indexing')}}
</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>


Expand All @@ -39,7 +47,7 @@
<label class="form-check-label font-weight-bold" for="is_suggestable">
{{__('Show on Directory')}}
</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 class="form-check pb-3">
Expand Down Expand Up @@ -97,10 +105,10 @@
<p class="text-muted small help-text mb-0">Enable your profile atom feed. Only public profiles are eligible.</p>
@if($settings->show_atom)
<p class="small">
<a href="{{$profile->permalink('.atom')}}" class="text-success font-weight-bold small" target="_blank">
{{ $profile->permalink('.atom') }}
<i class="far fa-external-link ml-1 text-muted" style="opacity: 0.5"></i>
</a>
<a href="{{$profile->permalink('.atom')}}" class="text-success font-weight-bold small" target="_blank">
{{ $profile->permalink('.atom') }}
<i class="far fa-external-link ml-1 text-muted" style="opacity: 0.5"></i>
</a>
</p>
@endif
</div>
Expand Down

0 comments on commit fc24630

Please sign in to comment.