Browse Source

Update ApiV1Controller, fix instance endpoint

Daniel Supernault 3 years ago
parent
commit
c383f1008d

+ 29 - 3
app/Http/Controllers/Api/ApiV1Controller.php

@@ -1236,11 +1236,13 @@ class ApiV1Controller extends Controller
 				'description' => 'Pixelfed is an image sharing platform, an ethical alternative to centralized platforms',
 				'description' => 'Pixelfed is an image sharing platform, an ethical alternative to centralized platforms',
 				'email' => config('instance.email'),
 				'email' => config('instance.email'),
 				'version' => '2.7.2 (compatible; Pixelfed ' . config('pixelfed.version') .')',
 				'version' => '2.7.2 (compatible; Pixelfed ' . config('pixelfed.version') .')',
-				'urls' => [],
+				'urls' => [
+					'streaming_api' => 'wss://' . config('pixelfed.domain.app')
+				],
 				'stats' => $stats,
 				'stats' => $stats,
-				'thumbnail' => url('headers/default.jpg'),
+				'thumbnail' => url('img/pixelfed-icon-color.png'),
 				'languages' => ['en'],
 				'languages' => ['en'],
-				'registrations' => (bool) config('pixelfed.open_registration'),
+				'registrations' => (bool) config_cache('pixelfed.open_registration'),
 				'approval_required' => false,
 				'approval_required' => false,
 				'contact_account' => $contact,
 				'contact_account' => $contact,
 				'rules' => $rules
 				'rules' => $rules
@@ -1434,6 +1436,30 @@ class ApiV1Controller extends Controller
 		return response()->json($res);
 		return response()->json($res);
 	}
 	}
 
 
+	/**
+	 * GET /api/v1/media/{id}
+	 *
+	 * @param  integer  $id
+	 *
+	 * @return MediaTransformer
+	 */
+	public function mediaGet(Request $request, $id)
+	{
+		abort_if(!$request->user(), 403);
+
+		$user = $request->user();
+
+		$media = Media::whereUserId($user->id)
+			->whereNull('status_id')
+			->findOrFail($id);
+
+		$resource = new Fractal\Resource\Item($media, new MediaTransformer());
+		$res = $this->fractal->createData($resource)->toArray();
+		$res['preview_url'] = url('/storage/no-preview.png');
+		$res['url'] = url('/storage/no-preview.png');
+		return response()->json($res);
+	}
+
 	/**
 	/**
 	 * GET /api/v1/mutes
 	 * GET /api/v1/mutes
 	 *
 	 *

+ 1 - 0
app/Transformer/Api/AccountTransformer.php

@@ -24,6 +24,7 @@ class AccountTransformer extends Fractal\TransformerAbstract
 			'username' => $username,
 			'username' => $username,
 			'acct' => $acct,
 			'acct' => $acct,
 			'display_name' => $profile->name,
 			'display_name' => $profile->name,
+			'discoverable' => true,
 			'locked' => (bool) $profile->is_private,
 			'locked' => (bool) $profile->is_private,
 			'followers_count' => (int) $profile->followerCount(),
 			'followers_count' => (int) $profile->followerCount(),
 			'following_count' => (int) $profile->followingCount(),
 			'following_count' => (int) $profile->followingCount(),