FederationController.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use App\Profile;
  5. use Auth;
  6. class FederationController extends Controller
  7. {
  8. public function authCheck()
  9. {
  10. if(!Auth::check()) {
  11. abort(403);
  12. }
  13. return;
  14. }
  15. public function remoteFollow()
  16. {
  17. $this->authCheck();
  18. return view('federation.remotefollow');
  19. }
  20. public function nodeinfoWellKnown()
  21. {
  22. $res = [
  23. 'links' => [
  24. [
  25. 'href' => config('pixelfed.nodeinfo.url'),
  26. 'rel' => 'http://nodeinfo.diaspora.software/ns/schema/2.0'
  27. ]
  28. ]
  29. ];
  30. return response()->json($res);
  31. }
  32. public function nodeinfo()
  33. {
  34. $res = [
  35. 'metadata' => [
  36. 'nodeName' => config('app.name'),
  37. 'software' => [
  38. 'homepage' => 'https://pixelfed.org',
  39. 'github' => 'https://github.com/pixelfed',
  40. 'follow' => 'https://mastodon.social/@pixelfed'
  41. ],
  42. /*
  43. TODO: Custom Features for Trending
  44. 'customFeatures' => [
  45. 'trending' => [
  46. 'description' => 'Trending API for federated discovery',
  47. 'api' => [
  48. 'url' => null,
  49. 'docs' => null
  50. ],
  51. ],
  52. ],
  53. */
  54. ],
  55. 'openRegistrations' => config('pixelfed.open_registration'),
  56. 'protocols' => [
  57. 'activitypub'
  58. ],
  59. 'services' => [
  60. 'inbound' => [],
  61. 'outbound' => []
  62. ],
  63. 'software' => [
  64. 'name' => 'PixelFed',
  65. 'version' => config('pixelfed.version')
  66. ],
  67. 'usage' => [
  68. 'localPosts' => \App\Status::whereLocal(true)->count(),
  69. 'users' => [
  70. 'total' => \App\User::count()
  71. ]
  72. ],
  73. 'version' => '2.0'
  74. ];
  75. return response()->json($res);
  76. }
  77. }