router.ex 23 KB
Newer Older
1
# Pleroma: A lightweight social networking server
kaniini's avatar
kaniini committed
2
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 4
# SPDX-License-Identifier: AGPL-3.0-only

lain's avatar
lain committed
5 6 7
defmodule Pleroma.Web.Router do
  use Pleroma.Web, :router

Ivan Tashkinov's avatar
Ivan Tashkinov committed
8 9 10 11 12
  pipeline :browser do
    plug(:accepts, ["html"])
    plug(:fetch_session)
  end

13 14 15
  pipeline :oauth do
    plug(:fetch_session)
    plug(Pleroma.Plugs.OAuthPlug)
16
    plug(Pleroma.Plugs.UserEnabledPlug)
17 18
  end

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

34
  pipeline :authenticated_api do
lain's avatar
lain committed
35 36 37
    plug(:accepts, ["json"])
    plug(:fetch_session)
    plug(Pleroma.Plugs.OAuthPlug)
lain's avatar
lain committed
38 39 40
    plug(Pleroma.Plugs.BasicAuthDecoderPlug)
    plug(Pleroma.Plugs.UserFetcherPlug)
    plug(Pleroma.Plugs.SessionAuthenticationPlug)
lain's avatar
lain committed
41
    plug(Pleroma.Plugs.LegacyAuthenticationPlug)
lain's avatar
lain committed
42
    plug(Pleroma.Plugs.AuthenticationPlug)
lain's avatar
lain committed
43 44
    plug(Pleroma.Plugs.UserEnabledPlug)
    plug(Pleroma.Plugs.SetUserSessionIdPlug)
lain's avatar
lain committed
45
    plug(Pleroma.Plugs.EnsureAuthenticatedPlug)
46
    plug(Pleroma.Plugs.IdempotencyPlug)
lain's avatar
lain committed
47 48
  end

Haelwenn's avatar
Haelwenn committed
49 50 51 52 53 54 55 56 57
  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)
58
    plug(Pleroma.Plugs.AdminSecretAuthenticationPlug)
Haelwenn's avatar
Haelwenn committed
59 60 61 62
    plug(Pleroma.Plugs.UserEnabledPlug)
    plug(Pleroma.Plugs.SetUserSessionIdPlug)
    plug(Pleroma.Plugs.EnsureAuthenticatedPlug)
    plug(Pleroma.Plugs.UserIsAdminPlug)
63
    plug(Pleroma.Plugs.IdempotencyPlug)
Haelwenn's avatar
Haelwenn committed
64 65
  end

lain's avatar
lain committed
66
  pipeline :mastodon_html do
lain's avatar
lain committed
67 68 69
    plug(:accepts, ["html"])
    plug(:fetch_session)
    plug(Pleroma.Plugs.OAuthPlug)
lain's avatar
lain committed
70 71 72
    plug(Pleroma.Plugs.BasicAuthDecoderPlug)
    plug(Pleroma.Plugs.UserFetcherPlug)
    plug(Pleroma.Plugs.SessionAuthenticationPlug)
lain's avatar
lain committed
73
    plug(Pleroma.Plugs.LegacyAuthenticationPlug)
lain's avatar
lain committed
74
    plug(Pleroma.Plugs.AuthenticationPlug)
lain's avatar
lain committed
75 76
    plug(Pleroma.Plugs.UserEnabledPlug)
    plug(Pleroma.Plugs.SetUserSessionIdPlug)
lain's avatar
lain committed
77
    plug(Pleroma.Plugs.EnsureUserKeyPlug)
lain's avatar
lain committed
78 79
  end

80
  pipeline :pleroma_html do
lain's avatar
lain committed
81 82 83
    plug(:accepts, ["html"])
    plug(:fetch_session)
    plug(Pleroma.Plugs.OAuthPlug)
lain's avatar
lain committed
84 85 86 87 88
    plug(Pleroma.Plugs.BasicAuthDecoderPlug)
    plug(Pleroma.Plugs.UserFetcherPlug)
    plug(Pleroma.Plugs.SessionAuthenticationPlug)
    plug(Pleroma.Plugs.AuthenticationPlug)
    plug(Pleroma.Plugs.EnsureUserKeyPlug)
89 90
  end

lain's avatar
lain committed
91
  pipeline :well_known do
lain's avatar
lain committed
92
    plug(:accepts, ["json", "jrd+json", "xml", "xrd+xml"])
lain's avatar
lain committed
93 94
  end

lain's avatar
lain committed
95
  pipeline :config do
lain's avatar
lain committed
96
    plug(:accepts, ["json", "xml"])
lain's avatar
lain committed
97 98
  end

eal's avatar
eal committed
99
  pipeline :pleroma_api do
lain's avatar
lain committed
100
    plug(:accepts, ["html", "json"])
Roger Braun's avatar
Roger Braun committed
101 102
  end

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

Maksim's avatar
Maksim committed
112 113
  pipeline :http_signature do
    plug(Pleroma.Web.Plugs.HTTPSignaturePlug)
114
    plug(Pleroma.Web.Plugs.MappedSignatureToIdentityPlug)
Maksim's avatar
Maksim committed
115 116
  end

Roger Braun's avatar
Roger Braun committed
117
  scope "/api/pleroma", Pleroma.Web.TwitterAPI do
lain's avatar
lain committed
118
    pipe_through(:pleroma_api)
119

120 121
    get("/password_reset/:token", PasswordController, :reset, as: :reset_password)
    post("/password_reset", PasswordController, :do_reset, as: :reset_password)
lain's avatar
lain committed
122
    get("/emoji", UtilController, :emoji)
123
    get("/captcha", UtilController, :captcha)
124
    get("/healthcheck", UtilController, :healthcheck)
Roger Braun's avatar
Roger Braun committed
125 126
  end

href's avatar
href committed
127 128 129 130 131
  scope "/api/pleroma", Pleroma.Web do
    pipe_through(:pleroma_api)
    post("/uploader_callback/:upload_path", UploaderController, :callback)
  end

Haelwenn's avatar
Haelwenn committed
132
  scope "/api/pleroma/admin", Pleroma.Web.AdminAPI do
133
    pipe_through(:admin_api)
134

Sachin Joshi's avatar
Sachin Joshi committed
135 136
    post("/users/follow", AdminAPIController, :user_follow)
    post("/users/unfollow", AdminAPIController, :user_unfollow)
137

Sachin Joshi's avatar
Sachin Joshi committed
138
    delete("/users", AdminAPIController, :user_delete)
139
    post("/users", AdminAPIController, :users_create)
Sachin Joshi's avatar
Sachin Joshi committed
140
    patch("/users/:nickname/toggle_activation", AdminAPIController, :user_toggle_activation)
141 142
    patch("/users/activate", AdminAPIController, :user_activate)
    patch("/users/deactivate", AdminAPIController, :user_deactivate)
143
    put("/users/tag", AdminAPIController, :tag_users)
144
    delete("/users/tag", AdminAPIController, :untag_users)
Haelwenn's avatar
Haelwenn committed
145

Sachin Joshi's avatar
Sachin Joshi committed
146 147
    get("/users/:nickname/permission_group", AdminAPIController, :right_get)
    get("/users/:nickname/permission_group/:permission_group", AdminAPIController, :right_get)
Maxim Filippov's avatar
Maxim Filippov committed
148

Sachin Joshi's avatar
Sachin Joshi committed
149 150 151 152 153 154 155 156
    post("/users/:nickname/permission_group/:permission_group", AdminAPIController, :right_add)

    delete(
      "/users/:nickname/permission_group/:permission_group",
      AdminAPIController,
      :right_delete
    )

Maxim Filippov's avatar
Maxim Filippov committed
157 158 159 160 161 162 163
    post("/users/permission_group/:permission_group", AdminAPIController, :right_add_multiple)

    delete(
      "/users/permission_group/:permission_group",
      AdminAPIController,
      :right_delete_multiple
    )
164

165
    get("/relay", AdminAPIController, :relay_list)
Haelwenn's avatar
Haelwenn committed
166 167 168
    post("/relay", AdminAPIController, :relay_follow)
    delete("/relay", AdminAPIController, :relay_unfollow)

Alexander Strizhakov's avatar
namings  
Alexander Strizhakov committed
169
    post("/users/invite_token", AdminAPIController, :create_invite_token)
Sachin Joshi's avatar
Sachin Joshi committed
170 171 172
    get("/users/invites", AdminAPIController, :invites)
    post("/users/revoke_invite", AdminAPIController, :revoke_invite)
    post("/users/email_invite", AdminAPIController, :email_invite)
173

Sachin Joshi's avatar
Sachin Joshi committed
174
    get("/users/:nickname/password_reset", AdminAPIController, :get_password_reset)
175
    patch("/users/force_password_reset", AdminAPIController, :force_password_reset)
Sachin Joshi's avatar
Sachin Joshi committed
176 177 178

    get("/users", AdminAPIController, :list_users)
    get("/users/:nickname", AdminAPIController, :user_show)
179
    get("/users/:nickname/statuses", AdminAPIController, :list_user_statuses)
Sergey Suprunenko's avatar
Sergey Suprunenko committed
180

181 182
    get("/instances/:instance/statuses", AdminAPIController, :list_instance_statuses)

183 184 185
    patch("/users/confirm_email", AdminAPIController, :confirm_email)
    patch("/users/resend_confirmation_email", AdminAPIController, :resend_confirmation_email)

Sergey Suprunenko's avatar
Sergey Suprunenko committed
186
    get("/reports", AdminAPIController, :list_reports)
187 188
    get("/grouped_reports", AdminAPIController, :list_grouped_reports_new)
    get("/grouped_reports_new", AdminAPIController, :list_grouped_reports_new)
Sergey Suprunenko's avatar
Sergey Suprunenko committed
189
    get("/reports/:id", AdminAPIController, :report_show)
190
    patch("/reports", AdminAPIController, :reports_update)
Maxim Filippov's avatar
Maxim Filippov committed
191
    post("/reports/:id/notes", AdminAPIController, :report_notes_create)
192
    delete("/reports/:report_id/notes/:id", AdminAPIController, :report_notes_delete)
Sergey Suprunenko's avatar
Sergey Suprunenko committed
193 194 195

    put("/statuses/:id", AdminAPIController, :status_update)
    delete("/statuses/:id", AdminAPIController, :status_delete)
196 197 198

    get("/config", AdminAPIController, :config_show)
    post("/config", AdminAPIController, :config_update)
199
    get("/config/descriptions", AdminAPIController, :config_descriptions)
200
    get("/restart", AdminAPIController, :restart)
Maxim Filippov's avatar
Maxim Filippov committed
201 202

    get("/moderation_log", AdminAPIController, :list_log)
vaartis's avatar
vaartis committed
203 204

    post("/reload_emoji", AdminAPIController, :reload_emoji)
Haelwenn's avatar
Haelwenn committed
205 206
  end

207
  scope "/api/pleroma/emoji", Pleroma.Web.PleromaAPI do
vaartis's avatar
vaartis committed
208 209
    scope "/packs" do
      # Modifying packs
210
      pipe_through(:admin_api)
vaartis's avatar
vaartis committed
211

212 213
      post("/import_from_fs", EmojiAPIController, :import_from_fs)

214 215 216 217
      post("/:pack_name/update_file", EmojiAPIController, :update_file)
      post("/:pack_name/update_metadata", EmojiAPIController, :update_metadata)
      put("/:name", EmojiAPIController, :create)
      delete("/:name", EmojiAPIController, :delete)
vaartis's avatar
vaartis committed
218
      post("/download_from", EmojiAPIController, :download_from)
219
      post("/list_from", EmojiAPIController, :list_from)
vaartis's avatar
vaartis committed
220 221 222 223
    end

    scope "/packs" do
      # Pack info / downloading
vaartis's avatar
vaartis committed
224
      get("/", EmojiAPIController, :list_packs)
225
      get("/:name/download_shared/", EmojiAPIController, :download_shared)
vaartis's avatar
vaartis committed
226 227 228
    end
  end

229
  scope "/", Pleroma.Web.TwitterAPI do
lain's avatar
lain committed
230
    pipe_through(:pleroma_html)
231

lain's avatar
lain committed
232
    post("/main/ostatus", UtilController, :remote_subscribe)
233
    get("/ostatus_subscribe", RemoteFollowController, :follow)
234

235
    post("/ostatus_subscribe", RemoteFollowController, :do_follow)
236 237
  end

eal's avatar
eal committed
238
  scope "/api/pleroma", Pleroma.Web.TwitterAPI do
lain's avatar
lain committed
239
    pipe_through(:authenticated_api)
240

241 242 243 244 245
    post("/change_email", UtilController, :change_email)
    post("/change_password", UtilController, :change_password)
    post("/delete_account", UtilController, :delete_account)
    put("/notification_settings", UtilController, :update_notificaton_settings)
    post("/disable_account", UtilController, :disable_account)
246

247 248
    post("/blocks_import", UtilController, :blocks_import)
    post("/follow_import", UtilController, :follow_import)
eal's avatar
eal committed
249 250
  end

251
  scope "/oauth", Pleroma.Web.OAuth do
252 253 254 255 256
    scope [] do
      pipe_through(:oauth)
      get("/authorize", OAuthController, :authorize)
    end

lain's avatar
lain committed
257 258
    post("/authorize", OAuthController, :create_authorization)
    post("/token", OAuthController, :token_exchange)
259
    post("/revoke", OAuthController, :token_revoke)
260
    get("/registration_details", OAuthController, :registration_details)
Ivan Tashkinov's avatar
Ivan Tashkinov committed
261 262 263 264

    scope [] do
      pipe_through(:browser)

265
      get("/prepare_request", OAuthController, :prepare_request)
Ivan Tashkinov's avatar
Ivan Tashkinov committed
266 267
      get("/:provider", OAuthController, :request)
      get("/:provider/callback", OAuthController, :callback)
268
      post("/register", OAuthController, :register)
Ivan Tashkinov's avatar
Ivan Tashkinov committed
269
    end
270 271
  end

272 273 274
  scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
    pipe_through(:api)

275
    get("/statuses/:id/reactions", PleromaAPIController, :emoji_reactions_by)
276 277
  end

278 279
  scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
    scope [] do
minibikini's avatar
minibikini committed
280
      pipe_through(:authenticated_api)
281

282
      get("/conversations/:id/statuses", PleromaAPIController, :conversation_statuses)
283
      get("/conversations/:id", PleromaAPIController, :conversation)
284
      post("/conversations/read", PleromaAPIController, :read_conversations)
285 286 287
    end

    scope [] do
minibikini's avatar
minibikini committed
288
      pipe_through(:authenticated_api)
289

290
      patch("/conversations/:id", PleromaAPIController, :update_conversation)
291 292
      put("/statuses/:id/reactions/:emoji", PleromaAPIController, :react_with_emoji)
      delete("/statuses/:id/reactions/:emoji", PleromaAPIController, :unreact_with_emoji)
293
      post("/notifications/read", PleromaAPIController, :read_notification)
minibikini's avatar
minibikini committed
294 295 296 297

      patch("/accounts/update_avatar", AccountController, :update_avatar)
      patch("/accounts/update_banner", AccountController, :update_banner)
      patch("/accounts/update_background", AccountController, :update_background)
298 299 300 301

      get("/mascot", MascotController, :show)
      put("/mascot", MascotController, :update)

minibikini's avatar
minibikini committed
302
      post("/scrobble", ScrobbleController, :new_scrobble)
303
    end
304 305

    scope [] do
minibikini's avatar
minibikini committed
306 307 308 309 310 311 312 313 314
      pipe_through(:api)
      get("/accounts/:id/favourites", AccountController, :favourites)
    end

    scope [] do
      pipe_through(:authenticated_api)

      post("/accounts/:id/subscribe", AccountController, :subscribe)
      post("/accounts/:id/unsubscribe", AccountController, :unsubscribe)
315
    end
minibikini's avatar
minibikini committed
316 317

    post("/accounts/confirmation_resend", AccountController, :confirmation_resend)
318 319 320
  end

  scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
321
    pipe_through(:api)
322
    get("/accounts/:id/scrobbles", ScrobbleController, :user_scrobbles)
323 324
  end

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

328
    get("/accounts/verify_credentials", AccountController, :verify_credentials)
329

330
    get("/accounts/relationships", AccountController, :relationships)
eal's avatar
eal committed
331

332 333
    get("/accounts/:id/lists", AccountController, :lists)
    get("/accounts/:id/identity_proofs", MastodonAPIController, :empty_array)
lain's avatar
lain committed
334

335 336 337
    get("/follow_requests", FollowRequestController, :index)
    get("/blocks", AccountController, :blocks)
    get("/mutes", AccountController, :mutes)
Roger Braun's avatar
Roger Braun committed
338

339 340
    get("/timelines/home", TimelineController, :home)
    get("/timelines/direct", TimelineController, :direct)
lain's avatar
lain committed
341

342 343
    get("/favourites", StatusController, :favourites)
    get("/bookmarks", StatusController, :bookmarks)
344

345 346 347 348 349
    get("/notifications", NotificationController, :index)
    get("/notifications/:id", NotificationController, :show)
    post("/notifications/clear", NotificationController, :clear)
    post("/notifications/dismiss", NotificationController, :dismiss)
    delete("/notifications/destroy_multiple", NotificationController, :destroy_multiple)
350

351 352
    get("/scheduled_statuses", ScheduledActivityController, :index)
    get("/scheduled_statuses/:id", ScheduledActivityController, :show)
Eugenij's avatar
Eugenij committed
353

354 355 356
    get("/lists", ListController, :index)
    get("/lists/:id", ListController, :show)
    get("/lists/:id/accounts", ListController, :list_accounts)
lain's avatar
lain committed
357

358
    get("/domain_blocks", DomainBlockController, :index)
359

360
    get("/filters", FilterController, :index)
lain's avatar
lain committed
361

362
    get("/suggestions", SuggestionController, :index)
eal's avatar
eal committed
363

364 365
    get("/conversations", ConversationController, :index)
    post("/conversations/:id/read", ConversationController, :read)
366

367
    get("/endorsements", AccountController, :endorsements)
eal's avatar
eal committed
368

369
    patch("/accounts/update_credentials", AccountController, :update_credentials)
hakabahitoyo's avatar
hakabahitoyo committed
370

371 372
    post("/statuses", StatusController, :create)
    delete("/statuses/:id", StatusController, :delete)
Haelwenn's avatar
Haelwenn committed
373

374 375 376 377 378 379 380 381 382 383
    post("/statuses/:id/reblog", StatusController, :reblog)
    post("/statuses/:id/unreblog", StatusController, :unreblog)
    post("/statuses/:id/favourite", StatusController, :favourite)
    post("/statuses/:id/unfavourite", StatusController, :unfavourite)
    post("/statuses/:id/pin", StatusController, :pin)
    post("/statuses/:id/unpin", StatusController, :unpin)
    post("/statuses/:id/bookmark", StatusController, :bookmark)
    post("/statuses/:id/unbookmark", StatusController, :unbookmark)
    post("/statuses/:id/mute", StatusController, :mute_conversation)
    post("/statuses/:id/unmute", StatusController, :unmute_conversation)
384

385 386
    put("/scheduled_statuses/:id", ScheduledActivityController, :update)
    delete("/scheduled_statuses/:id", ScheduledActivityController, :delete)
387

388
    post("/polls/:id/votes", PollController, :vote)
Eugenij's avatar
Eugenij committed
389

390 391
    post("/media", MediaController, :create)
    put("/media/:id", MediaController, :update)
rinpatch's avatar
rinpatch committed
392

393 394 395
    delete("/lists/:id", ListController, :delete)
    post("/lists", ListController, :create)
    put("/lists/:id", ListController, :update)
396

397 398
    post("/lists/:id/accounts", ListController, :add_to_list)
    delete("/lists/:id/accounts", ListController, :remove_from_list)
399

400 401 402 403
    post("/filters", FilterController, :create)
    get("/filters/:id", FilterController, :show)
    put("/filters/:id", FilterController, :update)
    delete("/filters/:id", FilterController, :delete)
404

405
    post("/reports", ReportController, :create)
406

407 408 409 410 411 412 413
    post("/follows", AccountController, :follows)
    post("/accounts/:id/follow", AccountController, :follow)
    post("/accounts/:id/unfollow", AccountController, :unfollow)
    post("/accounts/:id/block", AccountController, :block)
    post("/accounts/:id/unblock", AccountController, :unblock)
    post("/accounts/:id/mute", AccountController, :mute)
    post("/accounts/:id/unmute", AccountController, :unmute)
414

415 416
    post("/follow_requests/:id/authorize", FollowRequestController, :authorize)
    post("/follow_requests/:id/reject", FollowRequestController, :reject)
417

418 419
    post("/domain_blocks", DomainBlockController, :create)
    delete("/domain_blocks", DomainBlockController, :delete)
420

421 422 423 424
    post("/push/subscription", SubscriptionController, :create)
    get("/push/subscription", SubscriptionController, :get)
    put("/push/subscription", SubscriptionController, :update)
    delete("/push/subscription", SubscriptionController, :delete)
Maksim's avatar
Maksim committed
425 426 427

    get("/markers", MarkerController, :index)
    post("/markers", MarkerController, :upsert)
lain's avatar
lain committed
428 429
  end

minibikini's avatar
minibikini committed
430
  scope "/api/web", Pleroma.Web do
431
    pipe_through(:authenticated_api)
432

minibikini's avatar
minibikini committed
433
    put("/settings", MastoFEController, :put_settings)
434 435
  end

Roger Braun's avatar
Roger Braun committed
436
  scope "/api/v1", Pleroma.Web.MastodonAPI do
lain's avatar
lain committed
437
    pipe_through(:api)
438

439
    post("/accounts", AccountController, :create)
minibikini's avatar
minibikini committed
440
    get("/accounts/search", SearchController, :account_search)
441

442 443 444
    get("/instance", InstanceController, :show)
    get("/instance/peers", InstanceController, :peers)

445 446
    post("/apps", AppController, :create)
    get("/apps/verify_credentials", AppController, :verify_credentials)
447

448 449 450
    get("/statuses/:id/card", StatusController, :card)
    get("/statuses/:id/favourited_by", StatusController, :favourited_by)
    get("/statuses/:id/reblogged_by", StatusController, :reblogged_by)
lain's avatar
lain committed
451

minibikini's avatar
minibikini committed
452
    get("/custom_emojis", CustomEmojiController, :index)
Haelwenn's avatar
Haelwenn committed
453

minibikini's avatar
minibikini committed
454
    get("/trends", MastodonAPIController, :empty_array)
455

456 457 458
    get("/timelines/public", TimelineController, :public)
    get("/timelines/tag/:tag", TimelineController, :hashtag)
    get("/timelines/list/:list_id", TimelineController, :list)
459

460 461 462
    get("/statuses", StatusController, :index)
    get("/statuses/:id", StatusController, :show)
    get("/statuses/:id/context", StatusController, :context)
463

464
    get("/polls/:id", PollController, :show)
rinpatch's avatar
rinpatch committed
465

466 467 468 469
    get("/accounts/:id/statuses", AccountController, :statuses)
    get("/accounts/:id/followers", AccountController, :followers)
    get("/accounts/:id/following", AccountController, :following)
    get("/accounts/:id", AccountController, :show)
470

471
    get("/search", SearchController, :search)
Roger Braun's avatar
Roger Braun committed
472 473
  end

474
  scope "/api/v2", Pleroma.Web.MastodonAPI do
475
    pipe_through(:api)
476
    get("/search", SearchController, :search2)
477 478
  end

lain's avatar
lain committed
479
  scope "/api", Pleroma.Web do
lain's avatar
lain committed
480
    pipe_through(:config)
dtluna's avatar
dtluna committed
481

lain's avatar
lain committed
482 483 484 485
    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
486
    get("/pleroma/frontend_configurations", TwitterAPI.UtilController, :frontend_configurations)
lain's avatar
lain committed
487 488 489
  end

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

492 493 494 495 496 497
    get(
      "/account/confirm_email/:user_id/:token",
      TwitterAPI.Controller,
      :confirm_email,
      as: :confirm_email
    )
498 499 500
  end

  scope "/api", Pleroma.Web, as: :authenticated_twitter_api do
lain's avatar
lain committed
501
    pipe_through(:authenticated_api)
502

503 504
    get("/oauth_tokens", TwitterAPI.Controller, :oauth_tokens)
    delete("/oauth_tokens/:id", TwitterAPI.Controller, :revoke_token)
dtluna's avatar
dtluna committed
505

506
    post("/qvitter/statuses/notifications/read", TwitterAPI.Controller, :notifications_read)
lain's avatar
lain committed
507
  end
lain's avatar
lain committed
508

509
  pipeline :ap_service_actor do
510
    plug(:accepts, ["activity+json", "json"])
511 512
  end

lain's avatar
lain committed
513
  pipeline :ostatus do
514
    plug(:accepts, ["html", "xml", "atom", "activity+json", "json"])
515
    plug(Pleroma.Plugs.StaticFEPlug)
lain's avatar
lain committed
516 517
  end

518 519 520 521
  pipeline :oembed do
    plug(:accepts, ["json", "xml"])
  end

lain's avatar
lain committed
522
  scope "/", Pleroma.Web do
lain's avatar
lain committed
523
    pipe_through(:ostatus)
524
    pipe_through(:http_signature)
lain's avatar
lain committed
525

lain's avatar
lain committed
526 527 528
    get("/objects/:uuid", OStatus.OStatusController, :object)
    get("/activities/:uuid", OStatus.OStatusController, :activity)
    get("/notice/:id", OStatus.OStatusController, :notice)
href's avatar
href committed
529
    get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
530

Maksim's avatar
Maksim committed
531 532 533 534
    get("/users/:nickname/feed", Feed.UserController, :feed, as: :user_feed)
    get("/users/:nickname", Feed.UserController, :feed_redirect, as: :user_feed)

    get("/tags/:tag", Feed.TagController, :feed, as: :tag_feed)
535
  end
lain's avatar
lain committed
536

537 538
  scope "/", Pleroma.Web do
    pipe_through(:browser)
Roman Chvanikov's avatar
Roman Chvanikov committed
539
    get("/mailer/unsubscribe/:token", Mailer.SubscriptionController, :unsubscribe)
lain's avatar
lain committed
540 541
  end

lain's avatar
lain committed
542
  pipeline :activitypub do
543
    plug(:accepts, ["activity+json", "json"])
lain's avatar
lain committed
544
    plug(Pleroma.Web.Plugs.HTTPSignaturePlug)
545
    plug(Pleroma.Web.Plugs.MappedSignatureToIdentityPlug)
lain's avatar
lain committed
546 547
  end

548 549
  scope "/", Pleroma.Web.ActivityPub do
    # XXX: not really ostatus
lain's avatar
lain committed
550
    pipe_through(:ostatus)
551

lain's avatar
lain committed
552
    get("/users/:nickname/outbox", ActivityPubController, :outbox)
553 554
  end

555
  pipeline :activitypub_client do
556
    plug(:accepts, ["activity+json", "json"])
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571
    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.EnsureUserKeyPlug)
  end

  scope "/", Pleroma.Web.ActivityPub do
    pipe_through([:activitypub_client])

572 573
    get("/api/ap/whoami", ActivityPubController, :whoami)
    get("/users/:nickname/inbox", ActivityPubController, :read_inbox)
574

575 576
    post("/users/:nickname/outbox", ActivityPubController, :update_outbox)
    post("/api/ap/upload_media", ActivityPubController, :upload_media)
577

578 579
    get("/users/:nickname/followers", ActivityPubController, :followers)
    get("/users/:nickname/following", ActivityPubController, :following)
580 581
  end

582 583 584 585 586 587
  scope "/", Pleroma.Web.ActivityPub do
    pipe_through(:activitypub)
    post("/inbox", ActivityPubController, :inbox)
    post("/users/:nickname/inbox", ActivityPubController, :inbox)
  end

href's avatar
href committed
588
  scope "/relay", Pleroma.Web.ActivityPub do
589 590
    pipe_through(:ap_service_actor)

href's avatar
href committed
591
    get("/", ActivityPubController, :relay)
Maksim's avatar
Maksim committed
592 593 594 595 596

    scope [] do
      pipe_through(:http_signature)
      post("/inbox", ActivityPubController, :inbox)
    end
Maksim's avatar
Maksim committed
597 598 599

    get("/following", ActivityPubController, :following, assigns: %{relay: true})
    get("/followers", ActivityPubController, :followers, assigns: %{relay: true})
600 601 602 603 604 605 606
  end

  scope "/internal/fetch", Pleroma.Web.ActivityPub do
    pipe_through(:ap_service_actor)

    get("/", ActivityPubController, :internal_fetch)
    post("/inbox", ActivityPubController, :inbox)
href's avatar
href committed
607
  end
608

href's avatar
href committed
609 610
  scope "/.well-known", Pleroma.Web do
    pipe_through(:well_known)
lain's avatar
lain committed
611

href's avatar
href committed
612 613 614 615
    get("/host-meta", WebFinger.WebFingerController, :host_meta)
    get("/webfinger", WebFinger.WebFingerController, :webfinger)
    get("/nodeinfo", Nodeinfo.NodeinfoController, :schemas)
  end
dashie's avatar
dashie committed
616

href's avatar
href committed
617 618
  scope "/nodeinfo", Pleroma.Web do
    get("/:version", Nodeinfo.NodeinfoController, :nodeinfo)
lain's avatar
lain committed
619
  end
lain's avatar
lain committed
620

KokaKiwi's avatar
KokaKiwi committed
621 622 623 624 625 626
  scope "/", Pleroma.Web do
    pipe_through(:api)

    get("/web/manifest.json", MastoFEController, :manifest)
  end

minibikini's avatar
minibikini committed
627
  scope "/", Pleroma.Web do
lain's avatar
lain committed
628
    pipe_through(:mastodon_html)
lain's avatar
lain committed
629

minibikini's avatar
minibikini committed
630 631
    get("/web/login", MastodonAPI.AuthController, :login)
    delete("/auth/sign_out", MastodonAPI.AuthController, :logout)
632

minibikini's avatar
minibikini committed
633
    post("/auth/password", MastodonAPI.AuthController, :password_reset)
Alexander Strizhakov's avatar
Alexander Strizhakov committed
634

635
    get("/web/*path", MastoFEController, :index)
lain's avatar
lain committed
636 637
  end

href's avatar
href committed
638 639
  pipeline :remote_media do
  end
lain's avatar
lain committed
640

href's avatar
href committed
641
  scope "/proxy/", Pleroma.Web.MediaProxy do
lain's avatar
lain committed
642
    pipe_through(:remote_media)
643

lain's avatar
lain committed
644
    get("/:sig/:url", MediaProxyController, :remote)
href's avatar
href committed
645
    get("/:sig/:url/:filename", MediaProxyController, :remote)
href's avatar
href committed
646 647
  end

648
  if Pleroma.Config.get(:env) == :dev do
649 650 651 652 653
    scope "/dev" do
      pipe_through([:mailbox_preview])

      forward("/mailbox", Plug.Swoosh.MailboxPreview, base_path: "/dev/mailbox")
    end
href's avatar
href committed
654 655
  end

656 657 658 659 660
  scope "/", Pleroma.Web.MongooseIM do
    get("/user_exists", MongooseIMController, :user_exists)
    get("/check_password", MongooseIMController, :check_password)
  end

lain's avatar
lain committed
661
  scope "/", Fallback do
HJ's avatar
HJ committed
662
    get("/registration/:token", RedirectController, :registration_page)
663
    get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
664
    get("/api*path", RedirectController, :api_not_implemented)
665
    get("/*path", RedirectController, :redirector)
666 667

    options("/*path", RedirectController, :empty)
lain's avatar
lain committed
668 669
  end
end