defmodule Pleroma.Web.Router do
use Pleroma.Web, :router
- alias Pleroma.{Repo, User, Web.Router}
-
pipeline :api do
plug(:accepts, ["json"])
plug(:fetch_session)
plug(Pleroma.Plugs.EnsureAuthenticatedPlug)
end
+ pipeline :admin_api do
+ plug(:accepts, ["json"])
+ plug(:fetch_session)
+ plug(Pleroma.Plugs.OAuthPlug)
+ plug(Pleroma.Plugs.BasicAuthDecoderPlug)
+ plug(Pleroma.Plugs.UserFetcherPlug)
+ plug(Pleroma.Plugs.SessionAuthenticationPlug)
+ plug(Pleroma.Plugs.LegacyAuthenticationPlug)
+ plug(Pleroma.Plugs.AuthenticationPlug)
+ plug(Pleroma.Plugs.UserEnabledPlug)
+ plug(Pleroma.Plugs.SetUserSessionIdPlug)
+ plug(Pleroma.Plugs.EnsureAuthenticatedPlug)
+ plug(Pleroma.Plugs.UserIsAdminPlug)
+ end
+
pipeline :mastodon_html do
plug(:accepts, ["html"])
plug(:fetch_session)
plug(:accepts, ["html", "json"])
end
+ pipeline :mailbox_preview do
+ plug(:accepts, ["html"])
+
+ plug(:put_secure_browser_headers, %{
+ "content-security-policy" =>
+ "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' 'unsafe-eval'"
+ })
+ end
+
scope "/api/pleroma", Pleroma.Web.TwitterAPI do
pipe_through(:pleroma_api)
get("/password_reset/:token", UtilController, :show_password_reset)
get("/emoji", UtilController, :emoji)
end
+ scope "/api/pleroma/admin", Pleroma.Web.AdminAPI do
+ pipe_through(:admin_api)
+ delete("/user", AdminAPIController, :user_delete)
+ post("/user", AdminAPIController, :user_create)
+ put("/users/tag", AdminAPIController, :tag_users)
+ delete("/users/tag", AdminAPIController, :untag_users)
+
+ get("/permission_group/:nickname", AdminAPIController, :right_get)
+ get("/permission_group/:nickname/:permission_group", AdminAPIController, :right_get)
+ post("/permission_group/:nickname/:permission_group", AdminAPIController, :right_add)
+ delete("/permission_group/:nickname/:permission_group", AdminAPIController, :right_delete)
+
+ post("/relay", AdminAPIController, :relay_follow)
+ delete("/relay", AdminAPIController, :relay_unfollow)
+
+ get("/invite_token", AdminAPIController, :get_invite_token)
+ get("/password_reset", AdminAPIController, :get_password_reset)
+ end
+
scope "/", Pleroma.Web.TwitterAPI do
pipe_through(:pleroma_html)
get("/ostatus_subscribe", UtilController, :remote_follow)
put("/filters/:id", MastodonAPIController, :update_filter)
delete("/filters/:id", MastodonAPIController, :delete_filter)
+ post("/push/subscription", MastodonAPIController, :create_push_subscription)
+ get("/push/subscription", MastodonAPIController, :get_push_subscription)
+ put("/push/subscription", MastodonAPIController, :update_push_subscription)
+ delete("/push/subscription", MastodonAPIController, :delete_push_subscription)
+
get("/suggestions", MastodonAPIController, :suggestions)
get("/endorsements", MastodonAPIController, :empty_array)
get("/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation)
post("/account/register", TwitterAPI.Controller, :register)
+ post("/account/password_reset", TwitterAPI.Controller, :password_reset)
get("/search", TwitterAPI.Controller, :search)
get("/statusnet/tags/timeline/:tag", TwitterAPI.Controller, :public_and_external_timeline)
get("/statuses/networkpublic_timeline", TwitterAPI.Controller, :public_and_external_timeline)
end
- scope "/api", Pleroma.Web do
+ scope "/api", Pleroma.Web, as: :twitter_api_search do
+ pipe_through(:api)
+ get("/pleroma/search_user", TwitterAPI.Controller, :search_user)
+ end
+
+ scope "/api", Pleroma.Web, as: :authenticated_twitter_api do
pipe_through(:authenticated_api)
get("/account/verify_credentials", TwitterAPI.Controller, :verify_credentials)
post("/account/update_profile_banner", TwitterAPI.Controller, :update_banner)
post("/qvitter/update_background_image", TwitterAPI.Controller, :update_background)
- post(
- "/account/most_recent_notification",
- TwitterAPI.Controller,
- :update_most_recent_notification
- )
-
get("/statuses/home_timeline", TwitterAPI.Controller, :friends_timeline)
get("/statuses/friends_timeline", TwitterAPI.Controller, :friends_timeline)
get("/statuses/mentions", TwitterAPI.Controller, :mentions_timeline)
get("/statuses/mentions_timeline", TwitterAPI.Controller, :mentions_timeline)
+ get("/statuses/dm_timeline", TwitterAPI.Controller, :dm_timeline)
get("/qvitter/statuses/notifications", TwitterAPI.Controller, :notifications)
+ # XXX: this is really a pleroma API, but we want to keep the pleroma namespace clean
+ # for now.
+ post("/qvitter/statuses/notifications/read", TwitterAPI.Controller, :notifications_read)
+
post("/statuses/update", TwitterAPI.Controller, :status_update)
post("/statuses/retweet/:id", TwitterAPI.Controller, :retweet)
post("/statuses/unretweet/:id", TwitterAPI.Controller, :unretweet)
post("/statusnet/media/upload", TwitterAPI.Controller, :upload)
post("/media/upload", TwitterAPI.Controller, :upload_json)
+ post("/media/metadata/create", TwitterAPI.Controller, :update_media)
post("/favorites/create/:id", TwitterAPI.Controller, :favorite)
post("/favorites/create", TwitterAPI.Controller, :favorite)
end
pipeline :remote_media do
- plug(:accepts, ["html"])
end
scope "/proxy/", Pleroma.Web.MediaProxy do
pipe_through(:remote_media)
get("/:sig/:url", MediaProxyController, :remote)
+ get("/:sig/:url/:filename", MediaProxyController, :remote)
+ end
+
+ if Mix.env() == :dev do
+ scope "/dev" do
+ pipe_through([:mailbox_preview])
+
+ forward("/mailbox", Plug.Swoosh.MailboxPreview, base_path: "/dev/mailbox")
+ end
end
scope "/", Fallback do
use Pleroma.Web, :controller
def redirector(conn, _params) do
- if Mix.env() != :test do
- conn
- |> put_resp_content_type("text/html")
- |> send_file(200, "priv/static/index.html")
- end
+ conn
+ |> put_resp_content_type("text/html")
+ |> send_file(200, Application.app_dir(:pleroma, "priv/static/index.html"))
end
def registration_page(conn, params) do