router.ex 16.9 KB
Newer Older
lain's avatar
lain committed
1 2 3
defmodule Pleroma.Web.Router do
  use Pleroma.Web, :router

4
  alias Pleroma.{Repo, User, Web.Router}
5

lain's avatar
lain committed
6
  pipeline :api do
lain's avatar
lain committed
7 8 9
    plug(:accepts, ["json"])
    plug(:fetch_session)
    plug(Pleroma.Plugs.OAuthPlug)
lain's avatar
lain committed
10 11 12
    plug(Pleroma.Plugs.BasicAuthDecoderPlug)
    plug(Pleroma.Plugs.UserFetcherPlug)
    plug(Pleroma.Plugs.SessionAuthenticationPlug)
lain's avatar
lain committed
13
    plug(Pleroma.Plugs.LegacyAuthenticationPlug)
lain's avatar
lain committed
14
    plug(Pleroma.Plugs.AuthenticationPlug)
lain's avatar
lain committed
15 16
    plug(Pleroma.Plugs.UserEnabledPlug)
    plug(Pleroma.Plugs.SetUserSessionIdPlug)
lain's avatar
lain committed
17
    plug(Pleroma.Plugs.EnsureUserKeyPlug)
lain's avatar
lain committed
18 19
  end

20
  pipeline :authenticated_api do
lain's avatar
lain committed
21 22 23
    plug(:accepts, ["json"])
    plug(:fetch_session)
    plug(Pleroma.Plugs.OAuthPlug)
lain's avatar
lain committed
24 25 26
    plug(Pleroma.Plugs.BasicAuthDecoderPlug)
    plug(Pleroma.Plugs.UserFetcherPlug)
    plug(Pleroma.Plugs.SessionAuthenticationPlug)
lain's avatar
lain committed
27
    plug(Pleroma.Plugs.LegacyAuthenticationPlug)
lain's avatar
lain committed
28
    plug(Pleroma.Plugs.AuthenticationPlug)
lain's avatar
lain committed
29 30
    plug(Pleroma.Plugs.UserEnabledPlug)
    plug(Pleroma.Plugs.SetUserSessionIdPlug)
lain's avatar
lain committed
31
    plug(Pleroma.Plugs.EnsureAuthenticatedPlug)
lain's avatar
lain committed
32 33
  end

Haelwenn's avatar
Haelwenn committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
  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

lain's avatar
lain committed
49
  pipeline :mastodon_html do
lain's avatar
lain committed
50 51 52
    plug(:accepts, ["html"])
    plug(:fetch_session)
    plug(Pleroma.Plugs.OAuthPlug)
lain's avatar
lain committed
53 54 55
    plug(Pleroma.Plugs.BasicAuthDecoderPlug)
    plug(Pleroma.Plugs.UserFetcherPlug)
    plug(Pleroma.Plugs.SessionAuthenticationPlug)
lain's avatar
lain committed
56
    plug(Pleroma.Plugs.LegacyAuthenticationPlug)
lain's avatar
lain committed
57
    plug(Pleroma.Plugs.AuthenticationPlug)
lain's avatar
lain committed
58 59
    plug(Pleroma.Plugs.UserEnabledPlug)
    plug(Pleroma.Plugs.SetUserSessionIdPlug)
lain's avatar
lain committed
60
    plug(Pleroma.Plugs.EnsureUserKeyPlug)
lain's avatar
lain committed
61 62
  end

63
  pipeline :pleroma_html do
lain's avatar
lain committed
64 65 66
    plug(:accepts, ["html"])
    plug(:fetch_session)
    plug(Pleroma.Plugs.OAuthPlug)
lain's avatar
lain committed
67 68 69 70 71
    plug(Pleroma.Plugs.BasicAuthDecoderPlug)
    plug(Pleroma.Plugs.UserFetcherPlug)
    plug(Pleroma.Plugs.SessionAuthenticationPlug)
    plug(Pleroma.Plugs.AuthenticationPlug)
    plug(Pleroma.Plugs.EnsureUserKeyPlug)
72 73
  end

lain's avatar
lain committed
74
  pipeline :well_known do
lain's avatar
lain committed
75
    plug(:accepts, ["json", "jrd+json", "xml", "xrd+xml"])
lain's avatar
lain committed
76 77
  end

lain's avatar
lain committed
78
  pipeline :config do
lain's avatar
lain committed
79
    plug(:accepts, ["json", "xml"])
lain's avatar
lain committed
80 81
  end

82
  pipeline :oauth do
lain's avatar
lain committed
83
    plug(:accepts, ["html", "json"])
84 85
  end

eal's avatar
eal committed
86
  pipeline :pleroma_api do
lain's avatar
lain committed
87
    plug(:accepts, ["html", "json"])
Roger Braun's avatar
Roger Braun committed
88 89 90
  end

  scope "/api/pleroma", Pleroma.Web.TwitterAPI do
lain's avatar
lain committed
91 92 93 94
    pipe_through(:pleroma_api)
    get("/password_reset/:token", UtilController, :show_password_reset)
    post("/password_reset", UtilController, :password_reset)
    get("/emoji", UtilController, :emoji)
Roger Braun's avatar
Roger Braun committed
95 96
  end

Haelwenn's avatar
Haelwenn committed
97 98 99 100
  scope "/api/pleroma/admin", Pleroma.Web.AdminAPI do
    pipe_through(:admin_api)
    delete("/user", AdminAPIController, :user_delete)
    post("/user", AdminAPIController, :user_create)
101 102
    put("/users/tag", AdminAPIController, :tag_users)
    put("/users/untag", AdminAPIController, :untag_users)
Haelwenn's avatar
Haelwenn committed
103

104 105 106 107
    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)
Haelwenn's avatar
Haelwenn committed
108 109 110 111 112 113 114 115

    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

116
  scope "/", Pleroma.Web.TwitterAPI do
lain's avatar
lain committed
117 118 119 120
    pipe_through(:pleroma_html)
    get("/ostatus_subscribe", UtilController, :remote_follow)
    post("/ostatus_subscribe", UtilController, :do_remote_follow)
    post("/main/ostatus", UtilController, :remote_subscribe)
121 122
  end

eal's avatar
eal committed
123
  scope "/api/pleroma", Pleroma.Web.TwitterAPI do
lain's avatar
lain committed
124 125
    pipe_through(:authenticated_api)
    post("/follow_import", UtilController, :follow_import)
126
    post("/change_password", UtilController, :change_password)
127
    post("/delete_account", UtilController, :delete_account)
eal's avatar
eal committed
128 129
  end

130
  scope "/oauth", Pleroma.Web.OAuth do
lain's avatar
lain committed
131 132 133
    get("/authorize", OAuthController, :authorize)
    post("/authorize", OAuthController, :create_authorization)
    post("/token", OAuthController, :token_exchange)
134
    post("/revoke", OAuthController, :token_revoke)
135 136 137
  end

  scope "/api/v1", Pleroma.Web.MastodonAPI do
lain's avatar
lain committed
138
    pipe_through(:authenticated_api)
139

lain's avatar
lain committed
140 141 142 143 144 145 146 147 148 149
    patch("/accounts/update_credentials", MastodonAPIController, :update_credentials)
    get("/accounts/verify_credentials", MastodonAPIController, :verify_credentials)
    get("/accounts/relationships", MastodonAPIController, :relationships)
    get("/accounts/search", MastodonAPIController, :account_search)
    post("/accounts/:id/follow", MastodonAPIController, :follow)
    post("/accounts/:id/unfollow", MastodonAPIController, :unfollow)
    post("/accounts/:id/block", MastodonAPIController, :block)
    post("/accounts/:id/unblock", MastodonAPIController, :unblock)
    post("/accounts/:id/mute", MastodonAPIController, :relationship_noop)
    post("/accounts/:id/unmute", MastodonAPIController, :relationship_noop)
150
    get("/accounts/:id/lists", MastodonAPIController, :account_lists)
151

152
    get("/follow_requests", MastodonAPIController, :follow_requests)
kaniini's avatar
kaniini committed
153 154
    post("/follow_requests/:id/authorize", MastodonAPIController, :authorize_follow_request)
    post("/follow_requests/:id/reject", MastodonAPIController, :reject_follow_request)
155

lain's avatar
lain committed
156
    post("/follows", MastodonAPIController, :follow)
eal's avatar
eal committed
157

lain's avatar
lain committed
158
    get("/blocks", MastodonAPIController, :blocks)
lain's avatar
lain committed
159

lain's avatar
lain committed
160
    get("/mutes", MastodonAPIController, :empty_array)
Roger Braun's avatar
Roger Braun committed
161

lain's avatar
lain committed
162
    get("/timelines/home", MastodonAPIController, :home_timeline)
lain's avatar
lain committed
163

164 165
    get("/timelines/direct", MastodonAPIController, :dm_timeline)

lain's avatar
lain committed
166
    get("/favourites", MastodonAPIController, :favourites)
167

lain's avatar
lain committed
168 169
    post("/statuses", MastodonAPIController, :post_status)
    delete("/statuses/:id", MastodonAPIController, :delete_status)
lain's avatar
lain committed
170

lain's avatar
lain committed
171
    post("/statuses/:id/reblog", MastodonAPIController, :reblog_status)
normandy's avatar
normandy committed
172
    post("/statuses/:id/unreblog", MastodonAPIController, :unreblog_status)
lain's avatar
lain committed
173 174
    post("/statuses/:id/favourite", MastodonAPIController, :fav_status)
    post("/statuses/:id/unfavourite", MastodonAPIController, :unfav_status)
175

lain's avatar
lain committed
176 177 178 179
    post("/notifications/clear", MastodonAPIController, :clear_notifications)
    post("/notifications/dismiss", MastodonAPIController, :dismiss_notification)
    get("/notifications", MastodonAPIController, :notifications)
    get("/notifications/:id", MastodonAPIController, :get_notification)
lain's avatar
lain committed
180

lain's avatar
lain committed
181
    post("/media", MastodonAPIController, :upload)
182
    put("/media/:id", MastodonAPIController, :update_media)
eal's avatar
eal committed
183 184 185 186 187 188 189 190 191

    get("/lists", MastodonAPIController, :get_lists)
    get("/lists/:id", MastodonAPIController, :get_list)
    delete("/lists/:id", MastodonAPIController, :delete_list)
    post("/lists", MastodonAPIController, :create_list)
    put("/lists/:id", MastodonAPIController, :rename_list)
    get("/lists/:id/accounts", MastodonAPIController, :list_accounts)
    post("/lists/:id/accounts", MastodonAPIController, :add_to_list)
    delete("/lists/:id/accounts", MastodonAPIController, :remove_from_list)
eal's avatar
eal committed
192 193 194 195

    get("/domain_blocks", MastodonAPIController, :domain_blocks)
    post("/domain_blocks", MastodonAPIController, :block_domain)
    delete("/domain_blocks", MastodonAPIController, :unblock_domain)
hakabahitoyo's avatar
hakabahitoyo committed
196

Haelwenn's avatar
Haelwenn committed
197 198 199 200 201 202
    get("/filters", MastodonAPIController, :get_filters)
    post("/filters", MastodonAPIController, :create_filter)
    get("/filters/:id", MastodonAPIController, :get_filter)
    put("/filters/:id", MastodonAPIController, :update_filter)
    delete("/filters/:id", MastodonAPIController, :delete_filter)

hakabahitoyo's avatar
hakabahitoyo committed
203
    get("/suggestions", MastodonAPIController, :suggestions)
204 205

    get("/endorsements", MastodonAPIController, :empty_array)
lain's avatar
lain committed
206 207
  end

208 209 210 211 212 213
  scope "/api/web", Pleroma.Web.MastodonAPI do
    pipe_through(:authenticated_api)

    put("/settings", MastodonAPIController, :put_settings)
  end

Roger Braun's avatar
Roger Braun committed
214
  scope "/api/v1", Pleroma.Web.MastodonAPI do
lain's avatar
lain committed
215 216 217 218 219 220 221 222
    pipe_through(:api)
    get("/instance", MastodonAPIController, :masto_instance)
    get("/instance/peers", MastodonAPIController, :peers)
    post("/apps", MastodonAPIController, :create_app)
    get("/custom_emojis", MastodonAPIController, :custom_emojis)

    get("/timelines/public", MastodonAPIController, :public_timeline)
    get("/timelines/tag/:tag", MastodonAPIController, :hashtag_timeline)
eal's avatar
eal committed
223
    get("/timelines/list/:list_id", MastodonAPIController, :list_timeline)
lain's avatar
lain committed
224 225 226 227 228 229 230 231 232 233 234 235

    get("/statuses/:id", MastodonAPIController, :get_status)
    get("/statuses/:id/context", MastodonAPIController, :get_context)
    get("/statuses/:id/card", MastodonAPIController, :empty_object)
    get("/statuses/:id/favourited_by", MastodonAPIController, :favourited_by)
    get("/statuses/:id/reblogged_by", MastodonAPIController, :reblogged_by)

    get("/accounts/:id/statuses", MastodonAPIController, :user_statuses)
    get("/accounts/:id/followers", MastodonAPIController, :followers)
    get("/accounts/:id/following", MastodonAPIController, :following)
    get("/accounts/:id", MastodonAPIController, :user)

Haelwenn's avatar
Haelwenn committed
236 237
    get("/trends", MastodonAPIController, :empty_array)

lain's avatar
lain committed
238
    get("/search", MastodonAPIController, :search)
Roger Braun's avatar
Roger Braun committed
239 240
  end

241 242 243 244 245
  scope "/api/v2", Pleroma.Web.MastodonAPI do
    pipe_through(:api)
    get("/search", MastodonAPIController, :search2)
  end

lain's avatar
lain committed
246
  scope "/api", Pleroma.Web do
lain's avatar
lain committed
247
    pipe_through(:config)
dtluna's avatar
dtluna committed
248

lain's avatar
lain committed
249 250 251 252
    get("/help/test", TwitterAPI.UtilController, :help_test)
    post("/help/test", TwitterAPI.UtilController, :help_test)
    get("/statusnet/config", TwitterAPI.UtilController, :config)
    get("/statusnet/version", TwitterAPI.UtilController, :version)
lain's avatar
lain committed
253 254 255
  end

  scope "/api", Pleroma.Web do
lain's avatar
lain committed
256
    pipe_through(:api)
dtluna's avatar
dtluna committed
257

lain's avatar
lain committed
258 259 260 261 262 263 264 265
    get("/statuses/user_timeline", TwitterAPI.Controller, :user_timeline)
    get("/qvitter/statuses/user_timeline", TwitterAPI.Controller, :user_timeline)
    get("/users/show", TwitterAPI.Controller, :show_user)

    get("/statuses/followers", TwitterAPI.Controller, :followers)
    get("/statuses/friends", TwitterAPI.Controller, :friends)
    get("/statuses/show/:id", TwitterAPI.Controller, :fetch_status)
    get("/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation)
dtluna's avatar
dtluna committed
266

HJ's avatar
HJ committed
267
    post("/account/register", TwitterAPI.Controller, :register)
lain's avatar
lain committed
268

lain's avatar
lain committed
269 270
    get("/search", TwitterAPI.Controller, :search)
    get("/statusnet/tags/timeline/:tag", TwitterAPI.Controller, :public_and_external_timeline)
271 272
  end

lain's avatar
lain committed
273
  scope "/api", Pleroma.Web do
href's avatar
href committed
274
    pipe_through(:api)
lain's avatar
lain committed
275 276 277 278 279 280 281 282 283 284 285 286

    get("/statuses/public_timeline", TwitterAPI.Controller, :public_timeline)

    get(
      "/statuses/public_and_external_timeline",
      TwitterAPI.Controller,
      :public_and_external_timeline
    )

    get("/statuses/networkpublic_timeline", TwitterAPI.Controller, :public_and_external_timeline)
  end

287 288 289 290 291 292
  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
lain's avatar
lain committed
293
    pipe_through(:authenticated_api)
294

lain's avatar
lain committed
295 296
    get("/account/verify_credentials", TwitterAPI.Controller, :verify_credentials)
    post("/account/verify_credentials", TwitterAPI.Controller, :verify_credentials)
dtluna's avatar
dtluna committed
297

lain's avatar
lain committed
298 299 300
    post("/account/update_profile", TwitterAPI.Controller, :update_profile)
    post("/account/update_profile_banner", TwitterAPI.Controller, :update_banner)
    post("/qvitter/update_background_image", TwitterAPI.Controller, :update_background)
lain's avatar
lain committed
301

lain's avatar
lain committed
302 303 304 305
    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)
lain's avatar
lain committed
306
    get("/statuses/dm_timeline", TwitterAPI.Controller, :dm_timeline)
307
    get("/qvitter/statuses/notifications", TwitterAPI.Controller, :notifications)
dtluna's avatar
dtluna committed
308

309 310 311 312
    # 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)

lain's avatar
lain committed
313 314
    post("/statuses/update", TwitterAPI.Controller, :status_update)
    post("/statuses/retweet/:id", TwitterAPI.Controller, :retweet)
315
    post("/statuses/unretweet/:id", TwitterAPI.Controller, :unretweet)
lain's avatar
lain committed
316
    post("/statuses/destroy/:id", TwitterAPI.Controller, :delete_post)
dtluna's avatar
dtluna committed
317

318
    get("/pleroma/friend_requests", TwitterAPI.Controller, :friend_requests)
319 320
    post("/pleroma/friendships/approve", TwitterAPI.Controller, :approve_friend_request)
    post("/pleroma/friendships/deny", TwitterAPI.Controller, :deny_friend_request)
321

lain's avatar
lain committed
322 323 324 325
    post("/friendships/create", TwitterAPI.Controller, :follow)
    post("/friendships/destroy", TwitterAPI.Controller, :unfollow)
    post("/blocks/create", TwitterAPI.Controller, :block)
    post("/blocks/destroy", TwitterAPI.Controller, :unblock)
dtluna's avatar
dtluna committed
326

lain's avatar
lain committed
327 328
    post("/statusnet/media/upload", TwitterAPI.Controller, :upload)
    post("/media/upload", TwitterAPI.Controller, :upload_json)
329
    post("/media/metadata/create", TwitterAPI.Controller, :update_media)
dtluna's avatar
dtluna committed
330

lain's avatar
lain committed
331 332 333
    post("/favorites/create/:id", TwitterAPI.Controller, :favorite)
    post("/favorites/create", TwitterAPI.Controller, :favorite)
    post("/favorites/destroy/:id", TwitterAPI.Controller, :unfavorite)
dtluna's avatar
dtluna committed
334

lain's avatar
lain committed
335
    post("/qvitter/update_avatar", TwitterAPI.Controller, :update_avatar)
lain's avatar
lain committed
336

lain's avatar
lain committed
337 338
    get("/friends/ids", TwitterAPI.Controller, :friends_ids)
    get("/friendships/no_retweets/ids", TwitterAPI.Controller, :empty_array)
339

lain's avatar
lain committed
340
    get("/mutes/users/ids", TwitterAPI.Controller, :empty_array)
341
    get("/qvitter/mutes", TwitterAPI.Controller, :raw_empty_array)
342

lain's avatar
lain committed
343
    get("/externalprofile/show", TwitterAPI.Controller, :external_profile)
lain's avatar
lain committed
344
  end
lain's avatar
lain committed
345

346 347 348 349
  pipeline :ap_relay do
    plug(:accepts, ["activity+json"])
  end

lain's avatar
lain committed
350
  pipeline :ostatus do
lain's avatar
lain committed
351
    plug(:accepts, ["xml", "atom", "html", "activity+json"])
lain's avatar
lain committed
352 353
  end

lain's avatar
lain committed
354
  scope "/", Pleroma.Web do
lain's avatar
lain committed
355
    pipe_through(:ostatus)
lain's avatar
lain committed
356

lain's avatar
lain committed
357 358 359 360 361
    get("/objects/:uuid", OStatus.OStatusController, :object)
    get("/activities/:uuid", OStatus.OStatusController, :activity)
    get("/notice/:id", OStatus.OStatusController, :notice)
    get("/users/:nickname/feed", OStatus.OStatusController, :feed)
    get("/users/:nickname", OStatus.OStatusController, :feed_redirect)
lain's avatar
lain committed
362

href's avatar
href committed
363 364 365 366
    post("/users/:nickname/salmon", OStatus.OStatusController, :salmon_incoming)
    post("/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request)
    get("/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation)
    post("/push/subscriptions/:id", Websub.WebsubController, :websub_incoming)
lain's avatar
lain committed
367 368
  end

lain's avatar
lain committed
369
  pipeline :activitypub do
lain's avatar
lain committed
370 371
    plug(:accepts, ["activity+json"])
    plug(Pleroma.Web.Plugs.HTTPSignaturePlug)
lain's avatar
lain committed
372 373
  end

374 375
  scope "/", Pleroma.Web.ActivityPub do
    # XXX: not really ostatus
lain's avatar
lain committed
376
    pipe_through(:ostatus)
377

lain's avatar
lain committed
378 379 380
    get("/users/:nickname/followers", ActivityPubController, :followers)
    get("/users/:nickname/following", ActivityPubController, :following)
    get("/users/:nickname/outbox", ActivityPubController, :outbox)
381 382
  end

href's avatar
href committed
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
  scope "/relay", Pleroma.Web.ActivityPub do
    pipe_through(:ap_relay)
    get("/", ActivityPubController, :relay)
  end

  scope "/", Pleroma.Web.ActivityPub do
    pipe_through(:activitypub)
    post("/users/:nickname/inbox", ActivityPubController, :inbox)
    post("/inbox", ActivityPubController, :inbox)
  end

  scope "/.well-known", Pleroma.Web do
    pipe_through(:well_known)

    get("/host-meta", WebFinger.WebFingerController, :host_meta)
    get("/webfinger", WebFinger.WebFingerController, :webfinger)
    get("/nodeinfo", Nodeinfo.NodeinfoController, :schemas)
  end

  scope "/nodeinfo", Pleroma.Web do
    get("/:version", Nodeinfo.NodeinfoController, :nodeinfo)
lain's avatar
lain committed
404
  end
lain's avatar
lain committed
405

lain's avatar
lain committed
406
  scope "/", Pleroma.Web.MastodonAPI do
lain's avatar
lain committed
407
    pipe_through(:mastodon_html)
lain's avatar
lain committed
408

lain's avatar
lain committed
409 410 411 412
    get("/web/login", MastodonAPIController, :login)
    post("/web/login", MastodonAPIController, :login_post)
    get("/web/*path", MastodonAPIController, :index)
    delete("/auth/sign_out", MastodonAPIController, :logout)
lain's avatar
lain committed
413 414
  end

href's avatar
href committed
415 416
  pipeline :remote_media do
  end
lain's avatar
lain committed
417

href's avatar
href committed
418
  scope "/proxy/", Pleroma.Web.MediaProxy do
lain's avatar
lain committed
419 420
    pipe_through(:remote_media)
    get("/:sig/:url", MediaProxyController, :remote)
href's avatar
href committed
421
    get("/:sig/:url/:filename", MediaProxyController, :remote)
href's avatar
href committed
422 423
  end

lain's avatar
lain committed
424
  scope "/", Fallback do
HJ's avatar
HJ committed
425
    get("/registration/:token", RedirectController, :registration_page)
lain's avatar
lain committed
426
    get("/*path", RedirectController, :redirector)
427 428

    options("/*path", RedirectController, :empty)
lain's avatar
lain committed
429 430 431 432 433
  end
end

defmodule Fallback.RedirectController do
  use Pleroma.Web, :controller
lain's avatar
lain committed
434

lain's avatar
lain committed
435
  def redirector(conn, _params) do
href's avatar
href committed
436 437 438
    conn
    |> put_resp_content_type("text/html")
    |> send_file(200, Application.app_dir(:pleroma, "priv/static/index.html"))
lain's avatar
lain committed
439
  end
HJ's avatar
HJ committed
440 441 442 443

  def registration_page(conn, params) do
    redirector(conn, params)
  end
444 445 446 447 448 449

  def empty(conn, _params) do
    conn
    |> put_status(204)
    |> text("")
  end
lain's avatar
lain committed
450
end