mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-24 16:53:17 +00:00
Update FederationController
This commit is contained in:
parent
82add854a8
commit
a97403f3e7
1 changed files with 53 additions and 2 deletions
|
@ -2,9 +2,17 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Profile;
|
||||
use Auth;
|
||||
use App\Profile;
|
||||
use League\Fractal;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Util\Lexer\Nickname;
|
||||
use App\Util\Webfinger\Webfinger;
|
||||
use App\Transformer\ActivityPub\{
|
||||
ProfileOutbox,
|
||||
ProfileTransformer
|
||||
};
|
||||
use App\Jobs\RemoteFollowPipeline\RemoteFollowPipeline;
|
||||
|
||||
class FederationController extends Controller
|
||||
{
|
||||
|
@ -22,6 +30,25 @@ class FederationController extends Controller
|
|||
return view('federation.remotefollow');
|
||||
}
|
||||
|
||||
public function remoteFollowStore(Request $request)
|
||||
{
|
||||
$this->authCheck();
|
||||
$this->validate($request, [
|
||||
'url' => 'required|string'
|
||||
]);
|
||||
|
||||
if(config('pixelfed.remote_follow_enabled') !== true) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$follower = Auth::user()->profile;
|
||||
$url = $request->input('url');
|
||||
|
||||
RemoteFollowPipeline::dispatch($follower, $url);
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function nodeinfoWellKnown()
|
||||
{
|
||||
$res = [
|
||||
|
@ -81,4 +108,28 @@ class FederationController extends Controller
|
|||
|
||||
return response()->json($res);
|
||||
}
|
||||
|
||||
|
||||
public function webfinger(Request $request)
|
||||
{
|
||||
$this->validate($request, ['resource'=>'required']);
|
||||
$resource = $request->input('resource');
|
||||
$parsed = Nickname::normalizeProfileUrl($resource);
|
||||
$username = $parsed['username'];
|
||||
$user = Profile::whereUsername($username)->firstOrFail();
|
||||
$webfinger = (new Webfinger($user))->generate();
|
||||
return response()->json($webfinger);
|
||||
}
|
||||
|
||||
public function userOutbox(Request $request, $username)
|
||||
{
|
||||
$user = Profile::whereNull('remote_url')->whereUsername($username)->firstOrFail();
|
||||
|
||||
$timeline = $user->statuses()->orderBy('created_at','desc')->paginate(10);
|
||||
$fractal = new Fractal\Manager();
|
||||
$resource = new Fractal\Resource\Item($user, new ProfileOutbox);
|
||||
$res = $fractal->createData($resource)->toArray();
|
||||
return response()->json($res['data']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue