瀏覽代碼

Update Privacy Settings, add support for Mastodon indexable search flag

Daniel Supernault 1 年之前
父節點
當前提交
fc24630eba

+ 12 - 8
app/Http/Controllers/Settings/PrivacySettings.php

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

+ 7 - 0
app/Transformer/ActivityPub/ProfileTransformer.php

@@ -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(),

+ 28 - 0
database/migrations/2023_08_25_050021_add_indexable_column_to_profiles_table.php

@@ -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 - 0
resources/views/settings/partial/sidebar.blade.php

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

+ 15 - 7
resources/views/settings/privacy.blade.php

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