You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

723 lines
22 KiB

8 years ago
7 years ago
Add Keybase integration (#10297) * create account_identity_proofs table * add endpoint for keybase to check local proofs * add async task to update validity and liveness of proofs from keybase * first pass keybase proof CRUD * second pass keybase proof creation * clean up proof list and add badges * add avatar url to keybase api * Always highlight the “Identity Proofs” navigation item when interacting with proofs. * Update translations. * Add profile URL. * Reorder proofs. * Add proofs to bio. * Update settings/identity_proofs front-end. * Use `link_to`. * Only encode query params if they exist. URLs without params had a trailing `?`. * Only show live proofs. * change valid to active in proof list and update liveness before displaying * minor fixes * add keybase config at well-known path * extremely naive feature flagging off the identity proof UI * fixes for rubocop * make identity proofs page resilient to potential keybase issues * normalize i18n * tweaks for brakeman * remove two unused translations * cleanup and add more localizations * make keybase_contacts an admin setting * fix ExternalProofService my_domain * use Addressable::URI in identity proofs * use active model serializer for keybase proof config * more cleanup of keybase proof config * rename proof is_valid and is_live to proof_valid and proof_live * cleanup * assorted tweaks for more robust communication with keybase * Clean up * Small fixes * Display verified identity identically to verified links * Clean up unused CSS * Add caching for Keybase avatar URLs * Remove keybase_contacts setting
5 years ago
Add WebAuthn as an alternative 2FA method (#14466) * feat: add possibility of adding WebAuthn security keys to use as 2FA This adds a basic UI for enabling WebAuthn 2FA. We did a little refactor to the Settings page for editing the 2FA methods – now it will list the methods that are available to the user (TOTP and WebAuthn) and from there they'll be able to add or remove any of them. Also, it's worth mentioning that for enabling WebAuthn it's required to have TOTP enabled, so the first time that you go to the 2FA Settings page, you'll be asked to set it up. This work was inspired by the one donde by Github in their platform, and despite it could be approached in different ways, we decided to go with this one given that we feel that this gives a great UX. Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com> * feat: add request for WebAuthn as second factor at login if enabled This commits adds the feature for using WebAuthn as a second factor for login when enabled. If users have WebAuthn enabled, now a page requesting for the use of a WebAuthn credential for log in will appear, although a link redirecting to the old page for logging in using a two-factor code will also be present. Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com> * feat: add possibility of deleting WebAuthn Credentials Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com> * feat: disable WebAuthn when an Admin disables 2FA for a user Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com> * feat: remove ability to disable TOTP leaving only WebAuthn as 2FA Following examples form other platforms like Github, we decided to make Webauthn 2FA secondary to 2FA with TOTP, so that we removed the possibility of removing TOTP authentication only, leaving users with just WEbAuthn as 2FA. Instead, users will have to click on 'Disable 2FA' in order to remove second factor auth. The reason for WebAuthn being secondary to TOPT is that in that way, users will still be able to log in using their code from their phone's application if they don't have their security keys with them – or maybe even lost them. * We had to change a little the flow for setting up TOTP, given that now it's possible to setting up again if you already had TOTP, in order to let users modify their authenticator app – given that now it's not possible for them to disable TOTP and set it up again with another authenticator app. So, basically, now instead of storing the new `otp_secret` in the user, we store it in the session until the process of set up is finished. This was because, as it was before, when users clicked on 'Edit' in the new two-factor methods lists page, but then went back without finishing the flow, their `otp_secret` had been changed therefore invalidating their previous authenticator app, making them unable to log in again using TOTP. Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com> * refactor: fix eslint errors The PR build was failing given that linting returning some errors. This commit attempts to fix them. * refactor: normalize i18n translations The build was failing given that i18n translations files were not normalized. This commits fixes that. * refactor: avoid having the webauthn gem locked to a specific version * refactor: use symbols for routes without '/' * refactor: avoid sending webauthn disabled email when 2FA is disabled When an admins disable 2FA for users, we were sending two mails to them, one notifying that 2FA was disabled and the other to notify that WebAuthn was disabled. As the second one is redundant since the first email includes it, we can remove it and send just one email to users. * refactor: avoid creating new env variable for webauthn_origin config * refactor: improve flash error messages for webauthn pages Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com>
3 years ago
Add follower synchronization mechanism (#14510) * Add support for followers synchronization on the receiving end Check the `collectionSynchronization` attribute on `Create` and `Announce` activities and synchronize followers from provided collection if possible. * Add tests for followers synchronization on the receiving end * Add support for follower synchronization on the sender's end * Add tests for the sending end * Switch from AS attributes to HTTP header Replace the custom `collectionSynchronization` ActivityStreams attribute by an HTTP header (`X-AS-Collection-Synchronization`) with the same syntax as the `Signature` header and the following fields: - `collectionId` to specify which collection to synchronize - `digest` for the SHA256 hex-digest of the list of followers known on the receiving instance (where “receiving instance” is determined by accounts sharing the same host name for their ActivityPub actor `id`) - `url` of a collection that should be fetched by the instance actor Internally, move away from the webfinger-based `domain` attribute and use account `uri` prefix to group accounts. * Add environment variable to disable followers synchronization Since the whole mechanism relies on some new preconditions that, in some extremely rare cases, might not be met, add an environment variable (DISABLE_FOLLOWERS_SYNCHRONIZATION) to disable the mechanism altogether and avoid followers being incorrectly removed. The current conditions are: 1. all managed accounts' actor `id` and inbox URL have the same URI scheme and netloc. 2. all accounts whose actor `id` or inbox URL share the same URI scheme and netloc as a managed account must be managed by the same Mastodon instance as well. As far as Mastodon is concerned, breaking those preconditions require extensive configuration changes in the reverse proxy and might also cause other issues. Therefore, this environment variable provides a way out for people with highly unusual configurations, and can be safely ignored for the overwhelming majority of Mastodon administrators. * Only set follower synchronization header on non-public statuses This is to avoid unnecessary computations and allow Follow-related activities to be handled by the usual codepath instead of going through the synchronization mechanism (otherwise, any Follow/Undo/Accept activity would trigger the synchronization mechanism even if processing the activity itself would be enough to re-introduce synchronization) * Change how ActivityPub::SynchronizeFollowersService handles follow requests If the remote lists a local follower which we only know has sent a follow request, consider the follow request as accepted instead of sending an Undo. * Integrate review feeback - rename X-AS-Collection-Synchronization to Collection-Synchronization - various minor refactoring and code style changes * Only select required fields when computing followers_hash * Use actor URI rather than webfinger domain in synchronization endpoint * Change hash computation to be a XOR of individual hashes Makes it much easier to be memory-efficient, and avoid sorting discrepancy issues. * Marginally improve followers_hash computation speed * Further improve hash computation performances by using pluck_each
3 years ago
Add WebAuthn as an alternative 2FA method (#14466) * feat: add possibility of adding WebAuthn security keys to use as 2FA This adds a basic UI for enabling WebAuthn 2FA. We did a little refactor to the Settings page for editing the 2FA methods – now it will list the methods that are available to the user (TOTP and WebAuthn) and from there they'll be able to add or remove any of them. Also, it's worth mentioning that for enabling WebAuthn it's required to have TOTP enabled, so the first time that you go to the 2FA Settings page, you'll be asked to set it up. This work was inspired by the one donde by Github in their platform, and despite it could be approached in different ways, we decided to go with this one given that we feel that this gives a great UX. Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com> * feat: add request for WebAuthn as second factor at login if enabled This commits adds the feature for using WebAuthn as a second factor for login when enabled. If users have WebAuthn enabled, now a page requesting for the use of a WebAuthn credential for log in will appear, although a link redirecting to the old page for logging in using a two-factor code will also be present. Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com> * feat: add possibility of deleting WebAuthn Credentials Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com> * feat: disable WebAuthn when an Admin disables 2FA for a user Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com> * feat: remove ability to disable TOTP leaving only WebAuthn as 2FA Following examples form other platforms like Github, we decided to make Webauthn 2FA secondary to 2FA with TOTP, so that we removed the possibility of removing TOTP authentication only, leaving users with just WEbAuthn as 2FA. Instead, users will have to click on 'Disable 2FA' in order to remove second factor auth. The reason for WebAuthn being secondary to TOPT is that in that way, users will still be able to log in using their code from their phone's application if they don't have their security keys with them – or maybe even lost them. * We had to change a little the flow for setting up TOTP, given that now it's possible to setting up again if you already had TOTP, in order to let users modify their authenticator app – given that now it's not possible for them to disable TOTP and set it up again with another authenticator app. So, basically, now instead of storing the new `otp_secret` in the user, we store it in the session until the process of set up is finished. This was because, as it was before, when users clicked on 'Edit' in the new two-factor methods lists page, but then went back without finishing the flow, their `otp_secret` had been changed therefore invalidating their previous authenticator app, making them unable to log in again using TOTP. Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com> * refactor: fix eslint errors The PR build was failing given that linting returning some errors. This commit attempts to fix them. * refactor: normalize i18n translations The build was failing given that i18n translations files were not normalized. This commits fixes that. * refactor: avoid having the webauthn gem locked to a specific version * refactor: use symbols for routes without '/' * refactor: avoid sending webauthn disabled email when 2FA is disabled When an admins disable 2FA for users, we were sending two mails to them, one notifying that 2FA was disabled and the other to notify that WebAuthn was disabled. As the second one is redundant since the first email includes it, we can remove it and send just one email to users. * refactor: avoid creating new env variable for webauthn_origin config * refactor: improve flash error messages for webauthn pages Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com>
3 years ago
Support for import/export of instance-level domain blocks/allows for 4.x w/ additional fixes (#20597) * Allow import/export of instance-level domain blocks/allows (#1754) * Allow import/export of instance-level domain blocks/allows. Fixes #15095 * Pacify circleci * Address simple code review feedback * Add headers to exported CSV * Extract common import/export functionality to AdminExportControllerConcern * Add additional fields to instance-blocked domain export * Address review feedback * Split instance domain block/allow import/export into separate pages/controllers * Address code review feedback * Pacify DeepSource * Work around Paperclip::HasAttachmentFile for Rails 6 * Fix deprecated API warning in export tests * Remove after_commit workaround (cherry picked from commit 94e98864e39c010635e839fea984f2b4893bef1a) * Add confirmation page when importing blocked domains (#1773) * Move glitch-soc-specific strings to glitch-soc-specific locale files * Add confirmation page when importing blocked domains (cherry picked from commit b91196f4b73fff91997b8077619ae25b6d04a59e) * Fix authorization check in domain blocks controller (cherry picked from commit 75279377583c6e2aa04cc8d7380c593979630b38) * Fix error strings for domain blocks and email-domain blocks Corrected issue with non-error message used for Mastodon:NotPermittedError in Domain Blocks Corrected issue Domain Blocks using the Email Domain Blocks message on ActionContoller::ParameterMissing Corrected issue with Email Domain Blocks using the not_permitted string from "custom emojii's" * Ran i18n-tasks normalize to address test failure * Removed unused admin.export_domain_blocks.not_permitted string Removing unused string as indicated by Check i18n * Fix tests (cherry picked from commit 9094c2f52c24e1c00b594e7c11cd00e4a07eb431) * Fix domain block export not exporting blocks with only media rejection (cherry picked from commit 26ff48ee48a5c03a2a4b0bd03fd322529e6bd960) * Fix various issues with domain block import - stop using Paperclip for processing domain allow/block imports - stop leaving temporary files - better error handling - assume CSV files are UTF-8-encoded (cherry picked from commit cad824d8f501b95377e4f0a957e5a00d517a1902) Co-authored-by: Levi Bard <taktaktaktaktaktaktaktaktaktak@gmail.com> Co-authored-by: Claire <claire.github-309c@sitedethib.com>
1 year ago
Account domain blocks (#2381) * Add <ostatus:conversation /> tag to Atom input/output Only uses ref attribute (not href) because href would be the alternate link that's always included also. Creates new conversation for every non-reply status. Carries over conversation for every reply. Keeps remote URIs verbatim, generates local URIs on the fly like the rest of them. * Conversation muting - prevents notifications that reference a conversation (including replies, favourites, reblogs) from being created. API endpoints /api/v1/statuses/:id/mute and /api/v1/statuses/:id/unmute Currently no way to tell when a status/conversation is muted, so the web UI only has a "disable notifications" button, doesn't work as a toggle * Display "Dismiss notifications" on all statuses in notifications column, not just own * Add "muted" as a boolean attribute on statuses JSON For now always false on contained reblogs, since it's only relevant for statuses returned from the notifications endpoint, which are not nested Remove "Disable notifications" from detailed status view, since it's only relevant in the notifications column * Up max class length * Remove pending test for conversation mute * Add tests, clean up * Rename to "mute conversation" and "unmute conversation" * Raise validation error when trying to mute/unmute status without conversation * Adding account domain blocks that filter notifications and public timelines * Add tests for domain blocks in notifications, public timelines Filter reblogs of blocked domains from home * Add API for listing and creating account domain blocks * API for creating/deleting domain blocks, tests for Status#ancestors and Status#descendants, filter domain blocks from them * Filter domains in streaming API * Update account_domain_block_spec.rb
7 years ago
Support for import/export of instance-level domain blocks/allows for 4.x w/ additional fixes (#20597) * Allow import/export of instance-level domain blocks/allows (#1754) * Allow import/export of instance-level domain blocks/allows. Fixes #15095 * Pacify circleci * Address simple code review feedback * Add headers to exported CSV * Extract common import/export functionality to AdminExportControllerConcern * Add additional fields to instance-blocked domain export * Address review feedback * Split instance domain block/allow import/export into separate pages/controllers * Address code review feedback * Pacify DeepSource * Work around Paperclip::HasAttachmentFile for Rails 6 * Fix deprecated API warning in export tests * Remove after_commit workaround (cherry picked from commit 94e98864e39c010635e839fea984f2b4893bef1a) * Add confirmation page when importing blocked domains (#1773) * Move glitch-soc-specific strings to glitch-soc-specific locale files * Add confirmation page when importing blocked domains (cherry picked from commit b91196f4b73fff91997b8077619ae25b6d04a59e) * Fix authorization check in domain blocks controller (cherry picked from commit 75279377583c6e2aa04cc8d7380c593979630b38) * Fix error strings for domain blocks and email-domain blocks Corrected issue with non-error message used for Mastodon:NotPermittedError in Domain Blocks Corrected issue Domain Blocks using the Email Domain Blocks message on ActionContoller::ParameterMissing Corrected issue with Email Domain Blocks using the not_permitted string from "custom emojii's" * Ran i18n-tasks normalize to address test failure * Removed unused admin.export_domain_blocks.not_permitted string Removing unused string as indicated by Check i18n * Fix tests (cherry picked from commit 9094c2f52c24e1c00b594e7c11cd00e4a07eb431) * Fix domain block export not exporting blocks with only media rejection (cherry picked from commit 26ff48ee48a5c03a2a4b0bd03fd322529e6bd960) * Fix various issues with domain block import - stop using Paperclip for processing domain allow/block imports - stop leaving temporary files - better error handling - assume CSV files are UTF-8-encoded (cherry picked from commit cad824d8f501b95377e4f0a957e5a00d517a1902) Co-authored-by: Levi Bard <taktaktaktaktaktaktaktaktaktak@gmail.com> Co-authored-by: Claire <claire.github-309c@sitedethib.com>
1 year ago
Web Push Notifications (#3243) * feat: Register push subscription * feat: Notify when mentioned * feat: Boost, favourite, reply, follow, follow request * feat: Notification interaction * feat: Handle change of public key * feat: Unsubscribe if things go wrong * feat: Do not send normal notifications if push is enabled * feat: Focus client if open * refactor: Move push logic to WebPushSubscription * feat: Better title and body * feat: Localize messages * chore: Fix lint errors * feat: Settings * refactor: Lazy load * fix: Check if push settings exist * feat: Device-based preferences * refactor: Simplify logic * refactor: Pull request feedback * refactor: Pull request feedback * refactor: Create /api/web/push_subscriptions endpoint * feat: Spec PushSubscriptionController * refactor: WebPushSubscription => Web::PushSubscription * feat: Spec Web::PushSubscription * feat: Display first media attachment * feat: Support direction * fix: Stuff broken while rebasing * refactor: Integration with session activations * refactor: Cleanup * refactor: Simplify implementation * feat: Set VAPID keys via environment * chore: Comments * fix: Crash when no alerts * fix: Set VAPID keys in testing environment * fix: Follow link * feat: Notification actions * fix: Delete previous subscription * chore: Temporary logs * refactor: Move migration to a later date * fix: Fetch the correct session activation and misc bugs * refactor: Move migration to a later date * fix: Remove follow request (no notifications) * feat: Send administrator contact to push service * feat: Set time-to-live * fix: Do not show sensitive images * fix: Reducer crash in error handling * feat: Add badge * chore: Fix lint error * fix: Checkbox label overlap * fix: Check for payload support * fix: Rename action "type" (crash in latest Chrome) * feat: Action to expand notification * fix: Lint errors * fix: Unescape notification body * fix: Do not allow boosting if the status is hidden * feat: Add VAPID keys to the production sample environment * fix: Strip HTML tags from status * refactor: Better error messages * refactor: Handle browser not implementing the VAPID protocol (Samsung Internet) * fix: Error when target_status is nil * fix: Handle lack of image * fix: Delete reference to invalid subscriptions * feat: Better error handling * fix: Unescape HTML characters after tags are striped * refactor: Simpify code * fix: Modify to work with #4091 * Sort strings alphabetically * i18n: Updated Polish translation it annoys me that it's not fully localized :P * refactor: Use current_session in PushSubscriptionController * fix: Rebase mistake * fix: Set cacheName to mastodon * refactor: Pull request feedback * refactor: Remove logging statements * chore(yarn): Fix conflicts with master * chore(yarn): Copy latest from master * chore(yarn): Readd offline-plugin * refactor: Use save! and update! * refactor: Send notifications async * fix: Allow retry when push fails * fix: Save track for failed pushes * fix: Minify sw.js * fix: Remove account_id from fabricator
6 years ago
8 years ago
  1. # frozen_string_literal: true
  2. require 'sidekiq_unique_jobs/web'
  3. require 'sidekiq-scheduler/web'
  4. Rails.application.routes.draw do
  5. # Paths of routes on the web app that to not require to be indexed or
  6. # have alternative format representations requiring separate controllers
  7. web_app_paths = %w(
  8. /getting-started
  9. /keyboard-shortcuts
  10. /home
  11. /public
  12. /public/local
  13. /conversations
  14. /lists/(*any)
  15. /notifications
  16. /favourites
  17. /bookmarks
  18. /pinned
  19. /start
  20. /directory
  21. /explore/(*any)
  22. /search
  23. /publish
  24. /follow_requests
  25. /blocks
  26. /domain_blocks
  27. /mutes
  28. /followed_tags
  29. /statuses/(*any)
  30. ).freeze
  31. root 'home#index'
  32. mount LetterOpenerWeb::Engine, at: 'letter_opener' if Rails.env.development?
  33. get 'health', to: 'health#show'
  34. authenticate :user, lambda { |u| u.role&.can?(:view_devops) } do
  35. mount Sidekiq::Web, at: 'sidekiq', as: :sidekiq
  36. mount PgHero::Engine, at: 'pghero', as: :pghero
  37. end
  38. use_doorkeeper do
  39. controllers authorizations: 'oauth/authorizations',
  40. authorized_applications: 'oauth/authorized_applications',
  41. tokens: 'oauth/tokens'
  42. end
  43. get '.well-known/host-meta', to: 'well_known/host_meta#show', as: :host_meta, defaults: { format: 'xml' }
  44. get '.well-known/nodeinfo', to: 'well_known/nodeinfo#index', as: :nodeinfo, defaults: { format: 'json' }
  45. get '.well-known/webfinger', to: 'well_known/webfinger#show', as: :webfinger
  46. get '.well-known/change-password', to: redirect('/auth/edit')
  47. get '/nodeinfo/2.0', to: 'well_known/nodeinfo#show', as: :nodeinfo_schema
  48. get 'manifest', to: 'manifests#show', defaults: { format: 'json' }
  49. get 'intent', to: 'intents#show'
  50. get 'custom.css', to: 'custom_css#show', as: :custom_css
  51. resource :instance_actor, path: 'actor', only: [:show] do
  52. resource :inbox, only: [:create], module: :activitypub
  53. resource :outbox, only: [:show], module: :activitypub
  54. end
  55. devise_scope :user do
  56. get '/invite/:invite_code', to: 'auth/registrations#new', as: :public_invite
  57. namespace :auth do
  58. resource :setup, only: [:show, :update], controller: :setup
  59. resource :challenge, only: [:create], controller: :challenges
  60. get 'sessions/security_key_options', to: 'sessions#webauthn_options'
  61. end
  62. end
  63. devise_for :users, path: 'auth', format: false, controllers: {
  64. omniauth_callbacks: 'auth/omniauth_callbacks',
  65. sessions: 'auth/sessions',
  66. registrations: 'auth/registrations',
  67. passwords: 'auth/passwords',
  68. confirmations: 'auth/confirmations',
  69. }
  70. get '/users/:username', to: redirect('/@%{username}'), constraints: lambda { |req| req.format.nil? || req.format.html? }
  71. get '/users/:username/statuses/:id', to: redirect('/@%{username}/%{id}'), constraints: lambda { |req| req.format.nil? || req.format.html? }
  72. get '/authorize_follow', to: redirect { |_, request| "/authorize_interaction?#{request.params.to_query}" }
  73. resources :accounts, path: 'users', only: [:show], param: :username do
  74. resources :statuses, only: [:show] do
  75. member do
  76. get :activity
  77. get :embed
  78. end
  79. resources :replies, only: [:index], module: :activitypub
  80. end
  81. resources :followers, only: [:index], controller: :follower_accounts
  82. resources :following, only: [:index], controller: :following_accounts
  83. resource :follow, only: [:create], controller: :account_follow
  84. resource :unfollow, only: [:create], controller: :account_unfollow
  85. resource :outbox, only: [:show], module: :activitypub
  86. resource :inbox, only: [:create], module: :activitypub
  87. resource :claim, only: [:create], module: :activitypub
  88. resources :collections, only: [:show], module: :activitypub
  89. resource :followers_synchronization, only: [:show], module: :activitypub
  90. end
  91. resource :inbox, only: [:create], module: :activitypub
  92. get '/:encoded_at(*path)', to: redirect("/@%{path}"), constraints: { encoded_at: /%40/ }
  93. constraints(username: /[^@\/.]+/) do
  94. get '/@:username', to: 'accounts#show', as: :short_account
  95. get '/@:username/with_replies', to: 'accounts#show', as: :short_account_with_replies
  96. get '/@:username/media', to: 'accounts#show', as: :short_account_media
  97. get '/@:username/tagged/:tag', to: 'accounts#show', as: :short_account_tag
  98. end
  99. constraints(account_username: /[^@\/.]+/) do
  100. get '/@:account_username/following', to: 'following_accounts#index'
  101. get '/@:account_username/followers', to: 'follower_accounts#index'
  102. get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status
  103. get '/@:account_username/:id/embed', to: 'statuses#embed', as: :embed_short_account_status
  104. end
  105. get '/@:username_with_domain/(*any)', to: 'home#index', constraints: { username_with_domain: /([^\/])+?/ }, format: false
  106. get '/settings', to: redirect('/settings/profile')
  107. namespace :settings do
  108. resource :profile, only: [:show, :update] do
  109. resources :pictures, only: :destroy
  110. end
  111. get :preferences, to: redirect('/settings/preferences/appearance')
  112. namespace :preferences do
  113. resource :appearance, only: [:show, :update], controller: :appearance
  114. resource :notifications, only: [:show, :update]
  115. resource :other, only: [:show, :update], controller: :other
  116. end
  117. resource :import, only: [:show, :create]
  118. resource :export, only: [:show, :create]
  119. namespace :exports, constraints: { format: :csv } do
  120. resources :follows, only: :index, controller: :following_accounts
  121. resources :blocks, only: :index, controller: :blocked_accounts
  122. resources :mutes, only: :index, controller: :muted_accounts
  123. resources :lists, only: :index, controller: :lists
  124. resources :domain_blocks, only: :index, controller: :blocked_domains
  125. resources :bookmarks, only: :index, controller: :bookmarks
  126. end
  127. resources :two_factor_authentication_methods, only: [:index] do
  128. collection do
  129. post :disable
  130. end
  131. end
  132. resource :otp_authentication, only: [:show, :create], controller: 'two_factor_authentication/otp_authentication'
  133. resources :webauthn_credentials, only: [:index, :new, :create, :destroy],
  134. path: 'security_keys',
  135. controller: 'two_factor_authentication/webauthn_credentials' do
  136. collection do
  137. get :options
  138. end
  139. end
  140. namespace :two_factor_authentication do
  141. resources :recovery_codes, only: [:create]
  142. resource :confirmation, only: [:new, :create]
  143. end
  144. resources :applications, except: [:edit] do
  145. member do
  146. post :regenerate
  147. end
  148. end
  149. resource :delete, only: [:show, :destroy]
  150. resource :migration, only: [:show, :create]
  151. namespace :migration do
  152. resource :redirect, only: [:new, :create, :destroy]
  153. end
  154. resources :aliases, only: [:index, :create, :destroy]
  155. resources :sessions, only: [:destroy]
  156. resources :featured_tags, only: [:index, :create, :destroy]
  157. resources :login_activities, only: [:index]
  158. end
  159. namespace :disputes do
  160. resources :strikes, only: [:show, :index] do
  161. resource :appeal, only: [:create]
  162. end
  163. end
  164. resources :media, only: [:show] do
  165. get :player
  166. end
  167. resources :tags, only: [:show]
  168. resources :emojis, only: [:show]
  169. resources :invites, only: [:index, :create, :destroy]
  170. resources :filters, except: [:show] do
  171. resources :statuses, only: [:index], controller: 'filters/statuses' do
  172. collection do
  173. post :batch
  174. end
  175. end
  176. end
  177. resource :relationships, only: [:show, :update]
  178. resource :statuses_cleanup, controller: :statuses_cleanup, only: [:show, :update]
  179. get '/media_proxy/:id/(*any)', to: 'media_proxy#show', as: :media_proxy, format: false
  180. resource :authorize_interaction, only: [:show, :create]
  181. resource :share, only: [:show, :create]
  182. namespace :admin do
  183. get '/dashboard', to: 'dashboard#index'
  184. resources :domain_allows, only: [:new, :create, :show, :destroy]
  185. resources :domain_blocks, only: [:new, :create, :show, :destroy, :update, :edit] do
  186. collection do
  187. post :batch
  188. end
  189. end
  190. resources :export_domain_allows, only: [:new] do
  191. collection do
  192. get :export, constraints: { format: :csv }
  193. post :import
  194. end
  195. end
  196. resources :export_domain_blocks, only: [:new] do
  197. collection do
  198. get :export, constraints: { format: :csv }
  199. post :import
  200. end
  201. end
  202. resources :email_domain_blocks, only: [:index, :new, :create] do
  203. collection do
  204. post :batch
  205. end
  206. end
  207. resources :action_logs, only: [:index]
  208. resources :warning_presets, except: [:new]
  209. resources :announcements, except: [:show] do
  210. member do
  211. post :publish
  212. post :unpublish
  213. end
  214. end
  215. get '/settings', to: redirect('/admin/settings/branding')
  216. get '/settings/edit', to: redirect('/admin/settings/branding')
  217. namespace :settings do
  218. resource :branding, only: [:show, :update], controller: 'branding'
  219. resource :registrations, only: [:show, :update], controller: 'registrations'
  220. resource :content_retention, only: [:show, :update], controller: 'content_retention'
  221. resource :about, only: [:show, :update], controller: 'about'
  222. resource :appearance, only: [:show, :update], controller: 'appearance'
  223. resource :discovery, only: [:show, :update], controller: 'discovery'
  224. end
  225. resources :site_uploads, only: [:destroy]
  226. resources :invites, only: [:index, :create, :destroy] do
  227. collection do
  228. post :deactivate_all
  229. end
  230. end
  231. resources :relays, only: [:index, :new, :create, :destroy] do
  232. member do
  233. post :enable
  234. post :disable
  235. end
  236. end
  237. resources :instances, only: [:index, :show, :destroy], constraints: { id: /[^\/]+/ } do
  238. member do
  239. post :clear_delivery_errors
  240. post :restart_delivery
  241. post :stop_delivery
  242. end
  243. end
  244. resources :rules
  245. resources :webhooks do
  246. member do
  247. post :enable
  248. post :disable
  249. end
  250. resource :secret, only: [], controller: 'webhooks/secrets' do
  251. post :rotate
  252. end
  253. end
  254. resources :reports, only: [:index, :show] do
  255. resources :actions, only: [:create], controller: 'reports/actions' do
  256. collection do
  257. post :preview
  258. end
  259. end
  260. member do
  261. post :assign_to_self
  262. post :unassign
  263. post :reopen
  264. post :resolve
  265. end
  266. end
  267. resources :report_notes, only: [:create, :destroy]
  268. resources :accounts, only: [:index, :show, :destroy] do
  269. member do
  270. post :enable
  271. post :unsensitive
  272. post :unsilence
  273. post :unsuspend
  274. post :redownload
  275. post :remove_avatar
  276. post :remove_header
  277. post :memorialize
  278. post :approve
  279. post :reject
  280. post :unblock_email
  281. end
  282. collection do
  283. post :batch
  284. end
  285. resource :change_email, only: [:show, :update]
  286. resource :reset, only: [:create]
  287. resource :action, only: [:new, :create], controller: 'account_actions'
  288. resources :statuses, only: [:index, :show] do
  289. collection do
  290. post :batch
  291. end
  292. end
  293. resources :relationships, only: [:index]
  294. resource :confirmation, only: [:create] do
  295. collection do
  296. post :resend
  297. end
  298. end
  299. end
  300. resources :users, only: [] do
  301. resource :two_factor_authentication, only: [:destroy], controller: 'users/two_factor_authentications'
  302. resource :role, only: [:show, :update], controller: 'users/roles'
  303. end
  304. resources :custom_emojis, only: [:index, :new, :create] do
  305. collection do
  306. post :batch
  307. end
  308. end
  309. resources :ip_blocks, only: [:index, :new, :create] do
  310. collection do
  311. post :batch
  312. end
  313. end
  314. resources :roles, except: [:show]
  315. resources :account_moderation_notes, only: [:create, :destroy]
  316. resource :follow_recommendations, only: [:show, :update]
  317. resources :tags, only: [:show, :update]
  318. namespace :trends do
  319. resources :links, only: [:index] do
  320. collection do
  321. post :batch
  322. end
  323. end
  324. resources :tags, only: [:index] do
  325. collection do
  326. post :batch
  327. end
  328. end
  329. resources :statuses, only: [:index] do
  330. collection do
  331. post :batch
  332. end
  333. end
  334. namespace :links do
  335. resources :preview_card_providers, only: [:index], path: :publishers do
  336. collection do
  337. post :batch
  338. end
  339. end
  340. end
  341. end
  342. namespace :disputes do
  343. resources :appeals, only: [:index] do
  344. member do
  345. post :approve
  346. post :reject
  347. end
  348. end
  349. end
  350. end
  351. get '/admin', to: redirect('/admin/dashboard', status: 302)
  352. namespace :api, format: false do
  353. # OEmbed
  354. get '/oembed', to: 'oembed#show', as: :oembed
  355. # JSON / REST API
  356. namespace :v1 do
  357. resources :statuses, only: [:create, :show, :update, :destroy] do
  358. scope module: :statuses do
  359. resources :reblogged_by, controller: :reblogged_by_accounts, only: :index
  360. resources :favourited_by, controller: :favourited_by_accounts, only: :index
  361. resource :reblog, only: :create
  362. post :unreblog, to: 'reblogs#destroy'
  363. resource :favourite, only: :create
  364. post :unfavourite, to: 'favourites#destroy'
  365. resource :bookmark, only: :create
  366. post :unbookmark, to: 'bookmarks#destroy'
  367. resource :mute, only: :create
  368. post :unmute, to: 'mutes#destroy'
  369. resource :pin, only: :create
  370. post :unpin, to: 'pins#destroy'
  371. resource :history, only: :show
  372. resource :source, only: :show
  373. post :translate, to: 'translations#create'
  374. end
  375. member do
  376. get :context
  377. end
  378. end
  379. namespace :timelines do
  380. resource :home, only: :show, controller: :home
  381. resource :public, only: :show, controller: :public
  382. resources :tag, only: :show
  383. resources :list, only: :show
  384. end
  385. get '/streaming', to: 'streaming#index'
  386. get '/streaming/(*any)', to: 'streaming#index'
  387. resources :custom_emojis, only: [:index]
  388. resources :suggestions, only: [:index, :destroy]
  389. resources :scheduled_statuses, only: [:index, :show, :update, :destroy]
  390. resources :preferences, only: [:index]
  391. resources :announcements, only: [:index] do
  392. scope module: :announcements do
  393. resources :reactions, only: [:update, :destroy]
  394. end
  395. member do
  396. post :dismiss
  397. end
  398. end
  399. # namespace :crypto do
  400. # resources :deliveries, only: :create
  401. # namespace :keys do
  402. # resource :upload, only: [:create]
  403. # resource :query, only: [:create]
  404. # resource :claim, only: [:create]
  405. # resource :count, only: [:show]
  406. # end
  407. # resources :encrypted_messages, only: [:index] do
  408. # collection do
  409. # post :clear
  410. # end
  411. # end
  412. # end
  413. resources :conversations, only: [:index, :destroy] do
  414. member do
  415. post :read
  416. end
  417. end
  418. resources :media, only: [:create, :update, :show]
  419. resources :blocks, only: [:index]
  420. resources :mutes, only: [:index]
  421. resources :favourites, only: [:index]
  422. resources :bookmarks, only: [:index]
  423. resources :reports, only: [:create]
  424. resources :trends, only: [:index], controller: 'trends/tags'
  425. resources :filters, only: [:index, :create, :show, :update, :destroy]
  426. resources :endorsements, only: [:index]
  427. resources :markers, only: [:index, :create]
  428. namespace :apps do
  429. get :verify_credentials, to: 'credentials#show'
  430. end
  431. resources :apps, only: [:create]
  432. namespace :trends do
  433. resources :links, only: [:index]
  434. resources :tags, only: [:index]
  435. resources :statuses, only: [:index]
  436. end
  437. namespace :emails do
  438. resources :confirmations, only: [:create]
  439. end
  440. resource :instance, only: [:show] do
  441. resources :peers, only: [:index], controller: 'instances/peers'
  442. resources :rules, only: [:index], controller: 'instances/rules'
  443. resources :domain_blocks, only: [:index], controller: 'instances/domain_blocks'
  444. resource :privacy_policy, only: [:show], controller: 'instances/privacy_policies'
  445. resource :extended_description, only: [:show], controller: 'instances/extended_descriptions'
  446. resource :activity, only: [:show], controller: 'instances/activity'
  447. end
  448. resource :domain_blocks, only: [:show, :create, :destroy]
  449. resource :directory, only: [:show]
  450. resources :follow_requests, only: [:index] do
  451. member do
  452. post :authorize
  453. post :reject
  454. end
  455. end
  456. resources :notifications, only: [:index, :show] do
  457. collection do
  458. post :clear
  459. end
  460. member do
  461. post :dismiss
  462. end
  463. end
  464. namespace :accounts do
  465. get :verify_credentials, to: 'credentials#show'
  466. patch :update_credentials, to: 'credentials#update'
  467. resource :search, only: :show, controller: :search
  468. resource :lookup, only: :show, controller: :lookup
  469. resources :relationships, only: :index
  470. resources :familiar_followers, only: :index
  471. end
  472. resources :accounts, only: [:create, :show] do
  473. resources :statuses, only: :index, controller: 'accounts/statuses'
  474. resources :followers, only: :index, controller: 'accounts/follower_accounts'
  475. resources :following, only: :index, controller: 'accounts/following_accounts'
  476. resources :lists, only: :index, controller: 'accounts/lists'
  477. resources :identity_proofs, only: :index, controller: 'accounts/identity_proofs'
  478. resources :featured_tags, only: :index, controller: 'accounts/featured_tags'
  479. member do
  480. post :follow
  481. post :unfollow
  482. post :remove_from_followers
  483. post :block
  484. post :unblock
  485. post :mute
  486. post :unmute
  487. end
  488. resource :pin, only: :create, controller: 'accounts/pins'
  489. post :unpin, to: 'accounts/pins#destroy'
  490. resource :note, only: :create, controller: 'accounts/notes'
  491. end
  492. resources :tags, only: [:show] do
  493. member do
  494. post :follow
  495. post :unfollow
  496. end
  497. end
  498. resources :followed_tags, only: [:index]
  499. resources :lists, only: [:index, :create, :show, :update, :destroy] do
  500. resource :accounts, only: [:show, :create, :destroy], controller: 'lists/accounts'
  501. end
  502. namespace :featured_tags do
  503. get :suggestions, to: 'suggestions#index'
  504. end
  505. resources :featured_tags, only: [:index, :create, :destroy]
  506. resources :polls, only: [:create, :show] do
  507. resources :votes, only: :create, controller: 'polls/votes'
  508. end
  509. namespace :push do
  510. resource :subscription, only: [:create, :show, :update, :destroy]
  511. end
  512. namespace :admin do
  513. resources :accounts, only: [:index, :show, :destroy] do
  514. member do
  515. post :enable
  516. post :unsensitive
  517. post :unsilence
  518. post :unsuspend
  519. post :approve
  520. post :reject
  521. end
  522. resource :action, only: [:create], controller: 'account_actions'
  523. end
  524. resources :reports, only: [:index, :update, :show] do
  525. member do
  526. post :assign_to_self
  527. post :unassign
  528. post :reopen
  529. post :resolve
  530. end
  531. end
  532. resources :domain_allows, only: [:index, :show, :create, :destroy]
  533. resources :domain_blocks, only: [:index, :show, :update, :create, :destroy]
  534. resources :email_domain_blocks, only: [:index, :show, :create, :destroy]
  535. resources :ip_blocks, only: [:index, :show, :update, :create, :destroy]
  536. namespace :trends do
  537. resources :tags, only: [:index]
  538. resources :links, only: [:index]
  539. resources :statuses, only: [:index]
  540. end
  541. post :measures, to: 'measures#create'
  542. post :dimensions, to: 'dimensions#create'
  543. post :retention, to: 'retention#create'
  544. resources :canonical_email_blocks, only: [:index, :create, :show, :destroy] do
  545. collection do
  546. post :test
  547. end
  548. end
  549. end
  550. end
  551. namespace :v2 do
  552. get '/search', to: 'search#index', as: :search
  553. resources :media, only: [:create]
  554. resources :suggestions, only: [:index]
  555. resource :instance, only: [:show]
  556. resources :filters, only: [:index, :create, :show, :update, :destroy] do
  557. resources :keywords, only: [:index, :create], controller: 'filters/keywords'
  558. resources :statuses, only: [:index, :create], controller: 'filters/statuses'
  559. end
  560. namespace :filters do
  561. resources :keywords, only: [:show, :update, :destroy]
  562. resources :statuses, only: [:show, :destroy]
  563. end
  564. namespace :admin do
  565. resources :accounts, only: [:index]
  566. end
  567. end
  568. namespace :web do
  569. resource :settings, only: [:update]
  570. resource :embed, only: [:create]
  571. resources :push_subscriptions, only: [:create] do
  572. member do
  573. put :update
  574. end
  575. end
  576. end
  577. end
  578. web_app_paths.each do |path|
  579. get path, to: 'home#index'
  580. end
  581. get '/web/(*any)', to: redirect('/%{any}', status: 302), as: :web, defaults: { any: '' }, format: false
  582. get '/about', to: 'about#show'
  583. get '/about/more', to: redirect('/about')
  584. get '/privacy-policy', to: 'privacy#show', as: :privacy_policy
  585. get '/terms', to: redirect('/privacy-policy')
  586. match '/', via: [:post, :put, :patch, :delete], to: 'application#raise_not_found', format: false
  587. match '*unmatched_route', via: :all, to: 'application#raise_not_found', format: false
  588. end