Add nodeinfo
This commit is contained in:
parent
eecdf86849
commit
4a890a39f4
4 changed files with 83 additions and 9 deletions
28
lib/nulla_web/controllers/nodeinfo_controller.ex
Normal file
28
lib/nulla_web/controllers/nodeinfo_controller.ex
Normal file
|
@ -0,0 +1,28 @@
|
|||
defmodule NullaWeb.NodeinfoController do
|
||||
use NullaWeb, :controller
|
||||
alias Nulla.Repo
|
||||
alias Nulla.ActivityPub
|
||||
alias Nulla.Models.User
|
||||
alias Nulla.Models.InstanceSettings
|
||||
|
||||
def index(conn, _params) do
|
||||
instance_settings = InstanceSettings.get_instance_settings!()
|
||||
domain = instance_settings.domain
|
||||
|
||||
json(conn, ActivityPub.nodeinfo(domain))
|
||||
end
|
||||
|
||||
def show(conn, _params) do
|
||||
version = Application.spec(:nulla, :vsn) |> to_string()
|
||||
|
||||
users = %{
|
||||
total: 0,
|
||||
month: 0,
|
||||
halfyear: 0
|
||||
}
|
||||
|
||||
instance_settings = InstanceSettings.get_instance_settings!()
|
||||
|
||||
json(conn, ActivityPub.nodeinfo(version, users, instance_settings))
|
||||
end
|
||||
end
|
|
@ -5,7 +5,7 @@ defmodule NullaWeb.WebfingerController do
|
|||
alias Nulla.Models.User
|
||||
alias Nulla.Models.InstanceSettings
|
||||
|
||||
def show(conn, %{"resource" => resource}) do
|
||||
def index(conn, %{"resource" => resource}) do
|
||||
case Regex.run(~r/^acct:([^@]+)@(.+)$/, resource) do
|
||||
[_, username, domain] ->
|
||||
case User.get_user_by_username(username) do
|
||||
|
|
|
@ -11,17 +11,15 @@ defmodule NullaWeb.Router do
|
|||
end
|
||||
|
||||
pipeline :api do
|
||||
plug :accepts, ["activity+json", "ld+json"]
|
||||
|
||||
post "/inbox", InboxController, :receive
|
||||
post "/@:username/inbox", InboxController, :receive
|
||||
get "/@:username/outbox", OutboxController, :index
|
||||
plug :accepts, ["json"]
|
||||
end
|
||||
|
||||
scope "/", NullaWeb do
|
||||
pipe_through :browser
|
||||
|
||||
get "/.well-known/webfinger", WebfingerController, :show
|
||||
get "/.well-known/webfinger", WebfingerController, :index
|
||||
get "/.well-known/nodeinfo", NodeinfoController, :index
|
||||
get "/nodeinfo/2.0", NodeinfoController, :show
|
||||
|
||||
get "/@:username", UserController, :show
|
||||
get "/@:username/following", FollowController, :following
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue