From 88b8b379e74e1654b3527de7da619d60b4f08809 Mon Sep 17 00:00:00 2001 From: miraikumiko Date: Fri, 27 Jun 2025 16:50:24 +0200 Subject: [PATCH] Update routes --- lib/nulla_web/controllers/actor_controller.ex | 2 +- lib/nulla_web/router.ex | 38 +++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/lib/nulla_web/controllers/actor_controller.ex b/lib/nulla_web/controllers/actor_controller.ex index c4b8479..bfea76d 100644 --- a/lib/nulla_web/controllers/actor_controller.ex +++ b/lib/nulla_web/controllers/actor_controller.ex @@ -17,7 +17,7 @@ defmodule NullaWeb.ActorController do |> json(%{error: "Not Found"}) %Actor{} = actor -> - if accept in ["application/activity+json", "application/ld+json"] do + if accept in ["application/activity+json"] do conn |> put_resp_content_type("application/activity+json") |> send_resp(200, Jason.encode!(ActivityPub.actor(actor))) diff --git a/lib/nulla_web/router.ex b/lib/nulla_web/router.ex index 53d3633..31448b2 100644 --- a/lib/nulla_web/router.ex +++ b/lib/nulla_web/router.ex @@ -2,7 +2,7 @@ defmodule NullaWeb.Router do use NullaWeb, :router pipeline :browser do - plug :accepts, ["html", "json", "activity+json", "ld+json"] + plug :accepts, ["html", "json", "activity+json"] plug :fetch_session plug :fetch_live_flash plug :put_root_layout, html: {NullaWeb.Layouts, :root} @@ -14,6 +14,10 @@ defmodule NullaWeb.Router do plug :accepts, ["json"] end + pipeline :activitypub do + plug :accepts, ["activity+json"] + end + scope "/", NullaWeb do pipe_through :browser @@ -23,7 +27,6 @@ defmodule NullaWeb.Router do get "/.well-known/webfinger", WebfingerController, :index get "/.well-known/nodeinfo", NodeinfoController, :index get "/nodeinfo/2.0", NodeinfoController, :show - post "/inbox", InboxController, :inbox scope "/auth" do post "/", AuthController, :sign_up @@ -33,15 +36,6 @@ defmodule NullaWeb.Router do get "/sign_in", PageController, :sign_in end - scope "/users/:username" do - get "/", ActorController, :show - get "/following", FollowController, :following - get "/followers", FollowController, :followers - post "/inbox", InboxController, :inbox - get "/outbox", OutboxController, :outbox - get "/notes/:id", NoteController, :show - end - scope "/@:username" do get "/", ActorController, :show get "/following", FollowController, :following @@ -52,10 +46,24 @@ defmodule NullaWeb.Router do end end - # Other scopes may use custom stacks. - # scope "/api", NullaWeb do - # pipe_through :api - # end + scope "/api", NullaWeb do + pipe_through :api + end + + scope "/", NullaWeb do + pipe_through :activitypub + + post "/inbox", InboxController, :inbox + + scope "/users/:username" do + get "/", ActorController, :show + get "/following", FollowController, :following + get "/followers", FollowController, :followers + post "/inbox", InboxController, :inbox + get "/outbox", OutboxController, :outbox + get "/notes/:id", NoteController, :show + end + end # Enable LiveDashboard and Swoosh mailbox preview in development if Application.compile_env(:nulla, :dev_routes) do