router.ex 17.1 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
101
  scope "/api/pleroma/admin", Pleroma.Web.AdminAPI do
    pipe_through(:admin_api)
    delete("/user", AdminAPIController, :user_delete)
    post("/user", AdminAPIController, :user_create)

102
103
104
105
    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
106
107
108
109
110
111
112
113

    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

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

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

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

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

lain's avatar
lain committed
138
139
140
141
142
143
144
145
146
147
    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)
148
    get("/accounts/:id/lists", MastodonAPIController, :account_lists)
149

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

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

lain's avatar
lain committed
156
    get("/blocks", MastodonAPIController, :blocks)
lain's avatar
lain committed
157

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

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

162
163
    get("/timelines/direct", MastodonAPIController, :dm_timeline)

lain's avatar
lain committed
164
    get("/favourites", MastodonAPIController, :favourites)
165

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

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

lain's avatar
lain committed
174
175
176
177
    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
178

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

    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
190
191
192
193

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

Haelwenn's avatar
Haelwenn committed
195
196
197
198
199
200
    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)

201
202
203
204
205
    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)

hakabahitoyo's avatar
hakabahitoyo committed
206
    get("/suggestions", MastodonAPIController, :suggestions)
207
208

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

211
212
213
214
215
216
  scope "/api/web", Pleroma.Web.MastodonAPI do
    pipe_through(:authenticated_api)

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

Roger Braun's avatar
Roger Braun committed
217
  scope "/api/v1", Pleroma.Web.MastodonAPI do
lain's avatar
lain committed
218
219
220
221
222
223
224
225
    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
226
    get("/timelines/list/:list_id", MastodonAPIController, :list_timeline)
lain's avatar
lain committed
227
228
229
230
231
232
233
234
235
236
237
238

    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
239
240
    get("/trends", MastodonAPIController, :empty_array)

lain's avatar
lain committed
241
    get("/search", MastodonAPIController, :search)
Roger Braun's avatar
Roger Braun committed
242
243
  end

244
245
246
247
248
  scope "/api/v2", Pleroma.Web.MastodonAPI do
    pipe_through(:api)
    get("/search", MastodonAPIController, :search2)
  end

lain's avatar
lain committed
249
  scope "/api", Pleroma.Web do
lain's avatar
lain committed
250
    pipe_through(:config)
dtluna's avatar
dtluna committed
251

lain's avatar
lain committed
252
253
254
255
    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
256
257
258
  end

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

lain's avatar
lain committed
261
262
263
264
265
266
267
268
    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
269

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

lain's avatar
lain committed
272
273
    get("/search", TwitterAPI.Controller, :search)
    get("/statusnet/tags/timeline/:tag", TwitterAPI.Controller, :public_and_external_timeline)
274
275
  end

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

    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

290
291
292
293
294
295
  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
296
    pipe_through(:authenticated_api)
297

lain's avatar
lain committed
298
299
    get("/account/verify_credentials", TwitterAPI.Controller, :verify_credentials)
    post("/account/verify_credentials", TwitterAPI.Controller, :verify_credentials)
dtluna's avatar
dtluna committed
300

lain's avatar
lain committed
301
302
303
    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
304

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

312
313
314
315
    # 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
316
317
    post("/statuses/update", TwitterAPI.Controller, :status_update)
    post("/statuses/retweet/:id", TwitterAPI.Controller, :retweet)
318
    post("/statuses/unretweet/:id", TwitterAPI.Controller, :unretweet)
lain's avatar
lain committed
319
    post("/statuses/destroy/:id", TwitterAPI.Controller, :delete_post)
dtluna's avatar
dtluna committed
320

321
    get("/pleroma/friend_requests", TwitterAPI.Controller, :friend_requests)
322
323
    post("/pleroma/friendships/approve", TwitterAPI.Controller, :approve_friend_request)
    post("/pleroma/friendships/deny", TwitterAPI.Controller, :deny_friend_request)
324

lain's avatar
lain committed
325
326
327
328
    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
329

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

lain's avatar
lain committed
334
335
336
    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
337

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

lain's avatar
lain committed
340
341
    get("/friends/ids", TwitterAPI.Controller, :friends_ids)
    get("/friendships/no_retweets/ids", TwitterAPI.Controller, :empty_array)
342

lain's avatar
lain committed
343
    get("/mutes/users/ids", TwitterAPI.Controller, :empty_array)
344
    get("/qvitter/mutes", TwitterAPI.Controller, :raw_empty_array)
345

lain's avatar
lain committed
346
    get("/externalprofile/show", TwitterAPI.Controller, :external_profile)
lain's avatar
lain committed
347
  end
lain's avatar
lain committed
348

349
350
351
352
  pipeline :ap_relay do
    plug(:accepts, ["activity+json"])
  end

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

lain's avatar
lain committed
357
  scope "/", Pleroma.Web do
lain's avatar
lain committed
358
    pipe_through(:ostatus)
lain's avatar
lain committed
359

lain's avatar
lain committed
360
361
362
363
364
    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
365

href's avatar
href committed
366
367
368
369
    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
370
371
  end

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

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

lain's avatar
lain committed
381
382
383
    get("/users/:nickname/followers", ActivityPubController, :followers)
    get("/users/:nickname/following", ActivityPubController, :following)
    get("/users/:nickname/outbox", ActivityPubController, :outbox)
384
385
  end

href's avatar
href committed
386
387
388
389
  scope "/relay", Pleroma.Web.ActivityPub do
    pipe_through(:ap_relay)
    get("/", ActivityPubController, :relay)
  end
390

href's avatar
href committed
391
392
393
394
395
  scope "/", Pleroma.Web.ActivityPub do
    pipe_through(:activitypub)
    post("/users/:nickname/inbox", ActivityPubController, :inbox)
    post("/inbox", ActivityPubController, :inbox)
  end
lain's avatar
lain committed
396

href's avatar
href committed
397
398
  scope "/.well-known", Pleroma.Web do
    pipe_through(:well_known)
lain's avatar
lain committed
399

href's avatar
href committed
400
401
402
403
    get("/host-meta", WebFinger.WebFingerController, :host_meta)
    get("/webfinger", WebFinger.WebFingerController, :webfinger)
    get("/nodeinfo", Nodeinfo.NodeinfoController, :schemas)
  end
dashie's avatar
dashie committed
404

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

lain's avatar
lain committed
409
  scope "/", Pleroma.Web.MastodonAPI do
lain's avatar
lain committed
410
    pipe_through(:mastodon_html)
lain's avatar
lain committed
411

lain's avatar
lain committed
412
413
414
415
    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
416
417
  end

href's avatar
href committed
418
419
  pipeline :remote_media do
  end
lain's avatar
lain committed
420

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

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

    options("/*path", RedirectController, :empty)
lain's avatar
lain committed
432
433
434
435
436
  end
end

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

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

  def registration_page(conn, params) do
    redirector(conn, params)
  end
447
448
449
450
451
452

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