Merge pull request #4612 from pixelfed/staging

Add support for Mastodon indexable search flag
This commit is contained in:
daniel 2023-08-24 23:41:14 -06:00 committed by GitHub
commit 24db7d71cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 71 additions and 16 deletions

View file

@ -2,6 +2,11 @@
## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.11.9...dev)
### Federation
- Update Privacy Settings, add support for Mastodon `indexable` search flag ([fc24630e](https://github.com/pixelfed/pixelfed/commit/fc24630e))
- Update AP Helpers, consume actor `indexable` attribute ([fbdcdd9d](https://github.com/pixelfed/pixelfed/commit/fbdcdd9d))
- ([](https://github.com/pixelfed/pixelfed/commit/))
### Updates
- Update FollowerService, add forget method to RelationshipService call to reduce load when mass purging ([347e4f59](https://github.com/pixelfed/pixelfed/commit/347e4f59))
- Update FollowServiceWarmCache, improve handling larger following/follower lists ([61a6d904](https://github.com/pixelfed/pixelfed/commit/61a6d904))

View file

@ -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)
@ -39,11 +39,13 @@ trait PrivacySettings
'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);
@ -70,6 +72,8 @@ trait PrivacySettings
} else {
$settings->{$field} = false;
}
} elseif ($field == 'indexable') {
} else {
if ($form == 'on') {
$settings->{$field} = true;

View file

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

View file

@ -276,7 +276,7 @@ class Helpers {
}
if(is_array($val)) {
return !empty($val) ? $val[0] : null;
return !empty($val) ? head($val) : null;
}
return null;
@ -785,6 +785,7 @@ class Helpers {
'inbox_url' => $res['inbox'],
'outbox_url' => isset($res['outbox']) ? $res['outbox'] : null,
'public_key' => $res['publicKey']['publicKeyPem'],
'indexable' => isset($res['indexable']) && is_bool($res['indexable']) ? $res['indexable'] : false,
]
);

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) {
border-right: 1px solid #dee2e6 !important
}
height: 100%;
flex-grow: 1;
}
</style>
@endpush

View file

@ -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>
@ -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">
@ -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>