2020-01-26 20:36:50 +00:00
|
|
|
defmodule Mobilizon.Web.Router do
|
2018-01-14 16:56:50 +00:00
|
|
|
@moduledoc """
|
2018-10-11 15:37:39 +00:00
|
|
|
Router for mobilizon app
|
2018-01-14 16:56:50 +00:00
|
|
|
"""
|
2020-01-26 20:36:50 +00:00
|
|
|
use Mobilizon.Web, :router
|
2017-12-08 08:58:14 +00:00
|
|
|
|
2018-11-06 09:30:27 +00:00
|
|
|
pipeline :graphql do
|
2019-05-22 12:12:11 +00:00
|
|
|
# plug(:accepts, ["json"])
|
2020-01-26 20:36:50 +00:00
|
|
|
plug(Mobilizon.Web.Auth.Pipeline)
|
2017-12-08 08:58:14 +00:00
|
|
|
end
|
|
|
|
|
2018-05-17 09:32:23 +00:00
|
|
|
pipeline :well_known do
|
2018-11-07 15:45:11 +00:00
|
|
|
plug(:accepts, ["json", "jrd-json"])
|
2018-05-17 09:32:23 +00:00
|
|
|
end
|
|
|
|
|
2018-11-12 17:17:53 +00:00
|
|
|
pipeline :activity_pub_signature do
|
2020-01-26 20:36:50 +00:00
|
|
|
plug(Mobilizon.Web.Plugs.HTTPSignatures)
|
|
|
|
plug(Mobilizon.Web.Plugs.MappedSignatureToIdentity)
|
2018-05-17 09:32:23 +00:00
|
|
|
end
|
|
|
|
|
2019-07-30 14:40:59 +00:00
|
|
|
pipeline :relay do
|
2020-01-26 20:36:50 +00:00
|
|
|
plug(Mobilizon.Web.Plugs.HTTPSignatures)
|
|
|
|
plug(Mobilizon.Web.Plugs.MappedSignatureToIdentity)
|
2019-07-30 14:40:59 +00:00
|
|
|
plug(:accepts, ["activity-json", "json"])
|
|
|
|
end
|
|
|
|
|
2018-11-12 17:17:53 +00:00
|
|
|
pipeline :activity_pub do
|
2019-03-04 16:20:18 +00:00
|
|
|
plug(:accepts, ["activity-json"])
|
|
|
|
end
|
|
|
|
|
|
|
|
pipeline :activity_pub_and_html do
|
2019-03-05 11:24:29 +00:00
|
|
|
plug(:accepts, ["html", "activity-json"])
|
2020-02-18 07:57:00 +00:00
|
|
|
|
|
|
|
plug(Cldr.Plug.AcceptLanguage,
|
|
|
|
cldr_backend: Mobilizon.Cldr
|
|
|
|
)
|
2018-11-12 17:17:53 +00:00
|
|
|
end
|
|
|
|
|
2019-03-06 16:07:42 +00:00
|
|
|
pipeline :atom_and_ical do
|
|
|
|
plug(:accepts, ["atom", "ics", "html"])
|
2019-02-27 15:28:09 +00:00
|
|
|
end
|
|
|
|
|
2018-01-09 16:52:26 +00:00
|
|
|
pipeline :browser do
|
2019-07-05 14:59:25 +00:00
|
|
|
plug(Plug.Static, at: "/", from: "priv/static")
|
2020-02-18 07:57:00 +00:00
|
|
|
|
|
|
|
plug(Cldr.Plug.AcceptLanguage,
|
|
|
|
cldr_backend: Mobilizon.Cldr
|
|
|
|
)
|
|
|
|
|
2018-07-27 08:45:35 +00:00
|
|
|
plug(:accepts, ["html"])
|
|
|
|
plug(:fetch_session)
|
|
|
|
plug(:fetch_flash)
|
|
|
|
plug(:protect_from_forgery)
|
|
|
|
plug(:put_secure_browser_headers)
|
2018-01-09 16:52:26 +00:00
|
|
|
end
|
|
|
|
|
2019-05-28 08:51:02 +00:00
|
|
|
pipeline :remote_media do
|
|
|
|
end
|
|
|
|
|
2018-11-06 09:30:27 +00:00
|
|
|
scope "/api" do
|
|
|
|
pipe_through(:graphql)
|
2018-07-27 08:45:35 +00:00
|
|
|
|
2019-11-15 17:36:47 +00:00
|
|
|
forward("/", Absinthe.Plug,
|
2020-01-26 19:34:25 +00:00
|
|
|
schema: Mobilizon.GraphQL.Schema,
|
2019-11-15 17:36:47 +00:00
|
|
|
analyze_complexity: true,
|
|
|
|
max_complexity: 200
|
|
|
|
)
|
2017-12-08 08:58:14 +00:00
|
|
|
end
|
|
|
|
|
2020-01-26 20:36:50 +00:00
|
|
|
scope "/.well-known", Mobilizon.Web do
|
2018-07-27 08:45:35 +00:00
|
|
|
pipe_through(:well_known)
|
2018-05-17 09:32:23 +00:00
|
|
|
|
2018-07-27 08:45:35 +00:00
|
|
|
get("/host-meta", WebFingerController, :host_meta)
|
|
|
|
get("/webfinger", WebFingerController, :webfinger)
|
2018-11-06 09:30:27 +00:00
|
|
|
get("/nodeinfo", NodeInfoController, :schemas)
|
|
|
|
get("/nodeinfo/:version", NodeInfoController, :nodeinfo)
|
2018-05-17 09:32:23 +00:00
|
|
|
end
|
|
|
|
|
2020-01-26 20:36:50 +00:00
|
|
|
scope "/", Mobilizon.Web do
|
2019-03-04 16:20:18 +00:00
|
|
|
pipe_through(:activity_pub_and_html)
|
2019-12-03 10:29:51 +00:00
|
|
|
pipe_through(:activity_pub_signature)
|
|
|
|
|
2019-03-04 16:20:18 +00:00
|
|
|
get("/@:name", PageController, :actor)
|
2020-08-12 14:05:34 +00:00
|
|
|
get("/events/me", PageController, :my_events)
|
2020-08-12 15:55:38 +00:00
|
|
|
get("/events/create", PageController, :create_event)
|
2019-03-04 16:20:18 +00:00
|
|
|
get("/events/:uuid", PageController, :event)
|
|
|
|
get("/comments/:uuid", PageController, :comment)
|
2020-08-12 14:05:34 +00:00
|
|
|
get("/resource/:uuid", PageController, :resource)
|
|
|
|
get("/todo-list/:uuid", PageController, :todo_list)
|
|
|
|
get("/todo/:uuid", PageController, :todo)
|
2020-07-09 15:24:28 +00:00
|
|
|
get("/@:name/todos", PageController, :todos)
|
2020-02-18 07:57:00 +00:00
|
|
|
get("/@:name/resources", PageController, :resources)
|
2020-07-09 15:24:28 +00:00
|
|
|
get("/@:name/posts", PageController, :posts)
|
|
|
|
get("/@:name/discussions", PageController, :discussions)
|
|
|
|
get("/@:name/events", PageController, :events)
|
|
|
|
get("/p/:slug", PageController, :post)
|
|
|
|
get("/@:name/c/:slug", PageController, :discussion)
|
2019-03-04 16:20:18 +00:00
|
|
|
end
|
|
|
|
|
2020-01-26 20:36:50 +00:00
|
|
|
scope "/", Mobilizon.Web do
|
2019-02-27 15:28:09 +00:00
|
|
|
pipe_through(:activity_pub)
|
2020-07-09 15:24:28 +00:00
|
|
|
pipe_through(:activity_pub_signature)
|
2019-02-27 15:28:09 +00:00
|
|
|
|
2018-07-27 08:45:35 +00:00
|
|
|
get("/@:name/outbox", ActivityPubController, :outbox)
|
|
|
|
get("/@:name/following", ActivityPubController, :following)
|
|
|
|
get("/@:name/followers", ActivityPubController, :followers)
|
2020-02-18 07:57:00 +00:00
|
|
|
get("/@:name/members", ActivityPubController, :members)
|
2020-08-19 09:28:23 +00:00
|
|
|
get("/member/:uuid", ActivityPubController, :member)
|
2018-11-12 17:17:53 +00:00
|
|
|
end
|
|
|
|
|
2020-01-26 20:36:50 +00:00
|
|
|
scope "/", Mobilizon.Web do
|
2018-11-12 17:17:53 +00:00
|
|
|
pipe_through(:activity_pub_signature)
|
2018-07-27 08:45:35 +00:00
|
|
|
post("/@:name/inbox", ActivityPubController, :inbox)
|
|
|
|
post("/inbox", ActivityPubController, :inbox)
|
2017-12-08 08:58:14 +00:00
|
|
|
end
|
2018-01-09 16:52:26 +00:00
|
|
|
|
2020-01-26 20:36:50 +00:00
|
|
|
scope "/relay", Mobilizon.Web do
|
2019-07-30 14:40:59 +00:00
|
|
|
pipe_through(:relay)
|
|
|
|
|
|
|
|
get("/", ActivityPubController, :relay)
|
|
|
|
post("/inbox", ActivityPubController, :inbox)
|
|
|
|
end
|
|
|
|
|
2020-01-23 20:59:50 +00:00
|
|
|
## FEED
|
|
|
|
|
2020-01-26 20:36:50 +00:00
|
|
|
scope "/", Mobilizon.Web do
|
2020-01-23 20:59:50 +00:00
|
|
|
pipe_through(:atom_and_ical)
|
|
|
|
|
|
|
|
get("/@:name/feed/:format", FeedController, :actor)
|
|
|
|
get("/events/:uuid/export/:format", FeedController, :event)
|
|
|
|
get("/events/going/:token/:format", FeedController, :going)
|
|
|
|
end
|
|
|
|
|
|
|
|
## MOBILIZON
|
2019-12-20 12:04:34 +00:00
|
|
|
scope "/graphiql" do
|
|
|
|
pipe_through(:graphql)
|
|
|
|
forward("/", Absinthe.Plug.GraphiQL, schema: Mobilizon.GraphQL.Schema)
|
|
|
|
end
|
2020-01-23 20:59:50 +00:00
|
|
|
|
2020-01-26 20:36:50 +00:00
|
|
|
scope "/", Mobilizon.Web do
|
2020-01-23 20:59:50 +00:00
|
|
|
pipe_through(:browser)
|
|
|
|
|
|
|
|
# Because the "/events/:uuid" route caches all these, we need to force them
|
2020-08-12 14:05:34 +00:00
|
|
|
get("/events/create", PageController, :create_event)
|
|
|
|
get("/events/list", PageController, :list_events)
|
|
|
|
get("/events/me", PageController, :my_events)
|
|
|
|
get("/events/:uuid/edit", PageController, :edit_event)
|
2020-01-23 20:59:50 +00:00
|
|
|
|
|
|
|
# This is a hack to ease link generation into emails
|
2020-09-30 13:25:30 +00:00
|
|
|
get("/moderation/report/:id", PageController, :moderation_report)
|
2019-12-20 12:04:34 +00:00
|
|
|
|
2020-08-12 14:05:34 +00:00
|
|
|
get("/participation/email/confirm/:token", PageController, :participation_email_confirmation)
|
|
|
|
|
|
|
|
get("/validate/email/:token", PageController, :user_email_validation)
|
2019-12-20 12:04:34 +00:00
|
|
|
|
2020-08-12 14:05:34 +00:00
|
|
|
get("/groups/me", PageController, :my_groups)
|
2020-02-13 14:48:12 +00:00
|
|
|
|
2019-12-20 12:04:34 +00:00
|
|
|
get("/interact", PageController, :interact)
|
2020-06-27 17:12:45 +00:00
|
|
|
|
|
|
|
get("/auth/:provider", AuthController, :request)
|
|
|
|
get("/auth/:provider/callback", AuthController, :callback)
|
|
|
|
post("/auth/:provider/callback", AuthController, :callback)
|
2020-01-23 20:59:50 +00:00
|
|
|
end
|
|
|
|
|
2020-10-27 15:40:14 +00:00
|
|
|
if Application.fetch_env!(:mobilizon, :env) in [:dev, :e2e] do
|
2018-07-04 12:29:17 +00:00
|
|
|
# If using Phoenix
|
2018-07-27 08:45:35 +00:00
|
|
|
forward("/sent_emails", Bamboo.SentEmailViewerPlug)
|
2018-07-04 12:29:17 +00:00
|
|
|
end
|
|
|
|
|
2020-01-26 20:36:50 +00:00
|
|
|
scope "/", Mobilizon.Web do
|
2018-07-27 08:45:35 +00:00
|
|
|
pipe_through(:browser)
|
2018-01-09 16:52:26 +00:00
|
|
|
|
2018-07-27 08:45:35 +00:00
|
|
|
get("/*path", PageController, :index)
|
2018-01-09 16:52:26 +00:00
|
|
|
end
|
2017-12-08 08:58:14 +00:00
|
|
|
end
|