浏览代码

Add avatar to AP profile

Daniel Supernault 7 年之前
父节点
当前提交
c14314d70f
共有 2 个文件被更改,包括 8 次插入13 次删除
  1. 3 12
      app/Http/Controllers/ProfileController.php
  2. 5 1
      app/Transformer/ActivityPub/ProfileTransformer.php

+ 3 - 12
app/Http/Controllers/ProfileController.php

@@ -20,14 +20,10 @@ class ProfileController extends Controller
       $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(str_contains($request->header('accept'), $mimes) && config('pixelfed.activitypub_enabled')) {
+      if($request->wantsJson() && config('pixelfed.activitypub_enabled')) {
         return $this->showActivityPub($request, $user);
       }
+
       if($user->is_private == true) {
         $can_access = $this->privateProfileCheck($user);
         if($can_access !== true) {
@@ -53,12 +49,7 @@ class ProfileController extends Controller
       $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(str_contains($request->header('accept'), $mimes) && config('pixelfed.activitypub_enabled')) {
+      if($request->wantsJson() && config('pixelfed.activitypub_enabled')) {
         return $this->showActivityPub($request, $user);
       }
 

+ 5 - 1
app/Transformer/ActivityPub/ProfileTransformer.php

@@ -41,7 +41,11 @@ class ProfileTransformer extends Fractal\TransformerAbstract
           'endpoints' => [
             'sharedInbox' => config('routes.api.sharedInbox')
           ],
-              
+          'icon' => [
+            'type' => 'Image',
+            'mediaType' => 'image/jpeg',
+            'url' => $profile->avatarUrl()
+          ]
       ];
   }