Explorar o código

Merge pull request #369 from pixelfed/frontend-ui-refactor

Frontend ui refactor
daniel %!s(int64=7) %!d(string=hai) anos
pai
achega
44a0e1d1a0

+ 17 - 0
app/Http/Controllers/ProfileController.php

@@ -48,6 +48,23 @@ class ProfileController extends Controller
       return view('profile.show', compact('user', 'settings', 'owner', 'is_following', 'is_admin', 'timeline'));
     }
 
+    public function permalinkRedirect(Request $request, $username)
+    {
+      $user = Profile::whereUsername($username)->firstOrFail();
+      $settings = User::whereUsername($username)->firstOrFail()->settings;
+
+      $mimes = [
+        'application/activity+json', 
+        'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
+      ];
+
+      if(in_array($request->header('accept'), $mimes) && config('pixelfed.activitypub_enabled')) {
+        return $this->showActivityPub($request, $user);
+      }
+
+      return redirect($user->url());
+    }
+
     protected function privateProfileCheck(Profile $profile)
     {
       if(Auth::check() === false) {

+ 2 - 2
app/Transformer/ActivityPub/ProfileOutbox.php

@@ -13,7 +13,7 @@ class ProfileOutbox extends Fractal\TransformerAbstract
       $count = $profile->statuses()->count();
       $statuses = $profile->statuses()->has('media')->orderBy('id','desc')->take(20)->get()->map(function($i, $k) {
         $item = [
-          'id'  => $i->url(),
+          'id'  => $i->permalink(),
           // TODO: handle other types
           'type' => 'Create',
           'actor' => $i->profile->url(),
@@ -47,7 +47,7 @@ class ProfileOutbox extends Fractal\TransformerAbstract
               // TODO: add cc's
               //"{$notice->getProfile()->getUrl()}/subscribers",
             ],
-            'sensitive' => null,
+            'sensitive' => (bool) $i->is_nsfw,
             'atomUri' => $i->url(),
             'inReplyToAtomUri' => null,
             'conversation' => $i->url(),

+ 11 - 4
app/Transformer/ActivityPub/ProfileTransformer.php

@@ -11,7 +11,14 @@ class ProfileTransformer extends Fractal\TransformerAbstract
   public function transform(Profile $profile)
   {
       return [
-          '@context' => 'https://www.w3.org/ns/activitystreams',
+          '@context' => [
+            'https://www.w3.org/ns/activitystreams',
+            'https://w3id.org/security/v1',
+            [
+              "manuallyApprovesFollowers" => "as:manuallyApprovesFollowers",
+              "featured" => 'https://pixelfed.org/ns/featured',
+            ]
+          ],
           'id' => $profile->permalink(),
           'type' => 'Person',
           'following' => $profile->permalink('/following'),
@@ -23,9 +30,9 @@ class ProfileTransformer extends Fractal\TransformerAbstract
           'name'  => $profile->name,
           'summary' => $profile->bio,
           'url' => $profile->url(),
-          'manuallyApprovesFollowers' => $profile->is_private,
-          'follower_count' => $profile->followers()->count(),
-          'following_count' => $profile->following()->count(),
+          'manuallyApprovesFollowers' => (bool) $profile->is_private,
+          // 'follower_count' => $profile->followers()->count(),
+          // 'following_count' => $profile->following()->count(),
           'publicKey' => [
             'id' => $profile->permalink() . '#main-key',
             'owner' => $profile->permalink(),

+ 1 - 3
routes/web.php

@@ -123,9 +123,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware('validemail')->group(fu
     Route::redirect('/', '/');
     Route::get('{user}.atom', 'ProfileController@showAtomFeed');
     Route::get('{username}/outbox', 'FederationController@userOutbox');
-    Route::get('{user}', function($user) {
-      return redirect('/'.$user);
-    });
+    Route::get('{username}', 'ProfileController@permalinkRedirect');
   });
 
   Route::get('p/{username}/{id}/c/{cid}', 'CommentController@show');