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.

542 lines
17 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
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 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
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
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
4 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. root 'home#index'
  6. mount LetterOpenerWeb::Engine, at: 'letter_opener' if Rails.env.development?
  7. get 'health', to: 'health#show'
  8. authenticate :user, lambda { |u| u.admin? } do
  9. mount Sidekiq::Web, at: 'sidekiq', as: :sidekiq
  10. mount PgHero::Engine, at: 'pghero', as: :pghero
  11. end
  12. use_doorkeeper do
  13. controllers authorizations: 'oauth/authorizations',
  14. authorized_applications: 'oauth/authorized_applications',
  15. tokens: 'oauth/tokens'
  16. end
  17. get '.well-known/host-meta', to: 'well_known/host_meta#show', as: :host_meta, defaults: { format: 'xml' }
  18. get '.well-known/nodeinfo', to: 'well_known/nodeinfo#index', as: :nodeinfo, defaults: { format: 'json' }
  19. get '.well-known/webfinger', to: 'well_known/webfinger#show', as: :webfinger
  20. get '.well-known/change-password', to: redirect('/auth/edit')
  21. get '.well-known/keybase-proof-config', to: 'well_known/keybase_proof_config#show'
  22. get '/nodeinfo/2.0', to: 'well_known/nodeinfo#show', as: :nodeinfo_schema
  23. get 'manifest', to: 'manifests#show', defaults: { format: 'json' }
  24. get 'intent', to: 'intents#show'
  25. get 'custom.css', to: 'custom_css#show', as: :custom_css
  26. resource :instance_actor, path: 'actor', only: [:show] do
  27. resource :inbox, only: [:create], module: :activitypub
  28. resource :outbox, only: [:show], module: :activitypub
  29. end
  30. devise_scope :user do
  31. get '/invite/:invite_code', to: 'auth/registrations#new', as: :public_invite
  32. namespace :auth do
  33. resource :setup, only: [:show, :update], controller: :setup
  34. resource :challenge, only: [:create], controller: :challenges
  35. get 'sessions/security_key_options', to: 'sessions#webauthn_options'
  36. end
  37. end
  38. devise_for :users, path: 'auth', controllers: {
  39. omniauth_callbacks: 'auth/omniauth_callbacks',
  40. sessions: 'auth/sessions',
  41. registrations: 'auth/registrations',
  42. passwords: 'auth/passwords',
  43. confirmations: 'auth/confirmations',
  44. }
  45. get '/users/:username', to: redirect('/@%{username}'), constraints: lambda { |req| req.format.nil? || req.format.html? }
  46. get '/authorize_follow', to: redirect { |_, request| "/authorize_interaction?#{request.params.to_query}" }
  47. resources :accounts, path: 'users', only: [:show], param: :username do
  48. get :remote_follow, to: 'remote_follow#new'
  49. post :remote_follow, to: 'remote_follow#create'
  50. resources :statuses, only: [:show] do
  51. member do
  52. get :activity
  53. get :embed
  54. end
  55. resources :replies, only: [:index], module: :activitypub
  56. end
  57. resources :followers, only: [:index], controller: :follower_accounts
  58. resources :following, only: [:index], controller: :following_accounts
  59. resource :follow, only: [:create], controller: :account_follow
  60. resource :unfollow, only: [:create], controller: :account_unfollow
  61. resource :outbox, only: [:show], module: :activitypub
  62. resource :inbox, only: [:create], module: :activitypub
  63. resource :claim, only: [:create], module: :activitypub
  64. resources :collections, only: [:show], module: :activitypub
  65. resource :followers_synchronization, only: [:show], module: :activitypub
  66. end
  67. resource :inbox, only: [:create], module: :activitypub
  68. get '/@:username', to: 'accounts#show', as: :short_account
  69. get '/@:username/with_replies', to: 'accounts#show', as: :short_account_with_replies
  70. get '/@:username/media', to: 'accounts#show', as: :short_account_media
  71. get '/@:username/tagged/:tag', to: 'accounts#show', as: :short_account_tag
  72. get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status
  73. get '/@:account_username/:id/embed', to: 'statuses#embed', as: :embed_short_account_status
  74. get '/interact/:id', to: 'remote_interaction#new', as: :remote_interaction
  75. post '/interact/:id', to: 'remote_interaction#create'
  76. get '/explore', to: 'directories#index', as: :explore
  77. get '/settings', to: redirect('/settings/profile')
  78. namespace :settings do
  79. resource :profile, only: [:show, :update] do
  80. resources :pictures, only: :destroy
  81. end
  82. get :preferences, to: redirect('/settings/preferences/appearance')
  83. namespace :preferences do
  84. resource :appearance, only: [:show, :update], controller: :appearance
  85. resource :notifications, only: [:show, :update]
  86. resource :other, only: [:show, :update], controller: :other
  87. end
  88. resource :import, only: [:show, :create]
  89. resource :export, only: [:show, :create]
  90. namespace :exports, constraints: { format: :csv } do
  91. resources :follows, only: :index, controller: :following_accounts
  92. resources :blocks, only: :index, controller: :blocked_accounts
  93. resources :mutes, only: :index, controller: :muted_accounts
  94. resources :lists, only: :index, controller: :lists
  95. resources :domain_blocks, only: :index, controller: :blocked_domains
  96. resources :bookmarks, only: :index, controller: :bookmarks
  97. end
  98. resources :two_factor_authentication_methods, only: [:index] do
  99. collection do
  100. post :disable
  101. end
  102. end
  103. resource :otp_authentication, only: [:show, :create], controller: 'two_factor_authentication/otp_authentication'
  104. resources :webauthn_credentials, only: [:index, :new, :create, :destroy],
  105. path: 'security_keys',
  106. controller: 'two_factor_authentication/webauthn_credentials' do
  107. collection do
  108. get :options
  109. end
  110. end
  111. namespace :two_factor_authentication do
  112. resources :recovery_codes, only: [:create]
  113. resource :confirmation, only: [:new, :create]
  114. end
  115. resources :identity_proofs, only: [:index, :new, :create, :destroy]
  116. resources :applications, except: [:edit] do
  117. member do
  118. post :regenerate
  119. end
  120. end
  121. resource :delete, only: [:show, :destroy]
  122. resource :migration, only: [:show, :create]
  123. namespace :migration do
  124. resource :redirect, only: [:new, :create, :destroy]
  125. end
  126. resources :aliases, only: [:index, :create, :destroy]
  127. resources :sessions, only: [:destroy]
  128. resources :featured_tags, only: [:index, :create, :destroy]
  129. end
  130. resources :media, only: [:show] do
  131. get :player
  132. end
  133. resources :tags, only: [:show]
  134. resources :emojis, only: [:show]
  135. resources :invites, only: [:index, :create, :destroy]
  136. resources :filters, except: [:show]
  137. resource :relationships, only: [:show, :update]
  138. get '/public', to: 'public_timelines#show', as: :public_timeline
  139. get '/media_proxy/:id/(*any)', to: 'media_proxy#show', as: :media_proxy
  140. resource :authorize_interaction, only: [:show, :create]
  141. resource :share, only: [:show, :create]
  142. namespace :admin do
  143. get '/dashboard', to: 'dashboard#index'
  144. resources :domain_allows, only: [:new, :create, :show, :destroy]
  145. resources :domain_blocks, only: [:new, :create, :show, :destroy, :update, :edit]
  146. resources :email_domain_blocks, only: [:index, :new, :create, :destroy]
  147. resources :action_logs, only: [:index]
  148. resources :warning_presets, except: [:new]
  149. resources :announcements, except: [:show] do
  150. member do
  151. post :publish
  152. post :unpublish
  153. end
  154. end
  155. resource :settings, only: [:edit, :update]
  156. resources :site_uploads, only: [:destroy]
  157. resources :invites, only: [:index, :create, :destroy] do
  158. collection do
  159. post :deactivate_all
  160. end
  161. end
  162. resources :relays, only: [:index, :new, :create, :destroy] do
  163. member do
  164. post :enable
  165. post :disable
  166. end
  167. end
  168. resources :instances, only: [:index, :show], constraints: { id: /[^\/]+/ } do
  169. member do
  170. post :clear_delivery_errors
  171. post :restart_delivery
  172. post :stop_delivery
  173. end
  174. end
  175. resources :rules
  176. resources :reports, only: [:index, :show] do
  177. member do
  178. post :assign_to_self
  179. post :unassign
  180. post :reopen
  181. post :resolve
  182. end
  183. resources :reported_statuses, only: [:create]
  184. end
  185. resources :report_notes, only: [:create, :destroy]
  186. resources :accounts, only: [:index, :show, :destroy] do
  187. member do
  188. post :enable
  189. post :unsensitive
  190. post :unsilence
  191. post :unsuspend
  192. post :redownload
  193. post :remove_avatar
  194. post :remove_header
  195. post :memorialize
  196. post :approve
  197. post :reject
  198. end
  199. resource :change_email, only: [:show, :update]
  200. resource :reset, only: [:create]
  201. resource :action, only: [:new, :create], controller: 'account_actions'
  202. resources :statuses, only: [:index, :show, :create, :update, :destroy]
  203. resources :relationships, only: [:index]
  204. resource :confirmation, only: [:create] do
  205. collection do
  206. post :resend
  207. end
  208. end
  209. resource :role, only: [] do
  210. member do
  211. post :promote
  212. post :demote
  213. end
  214. end
  215. end
  216. resources :pending_accounts, only: [:index] do
  217. collection do
  218. post :approve_all
  219. post :reject_all
  220. post :batch
  221. end
  222. end
  223. resources :users, only: [] do
  224. resource :two_factor_authentication, only: [:destroy]
  225. end
  226. resources :custom_emojis, only: [:index, :new, :create] do
  227. collection do
  228. post :batch
  229. end
  230. end
  231. resources :ip_blocks, only: [:index, :new, :create] do
  232. collection do
  233. post :batch
  234. end
  235. end
  236. resources :account_moderation_notes, only: [:create, :destroy]
  237. resource :follow_recommendations, only: [:show, :update]
  238. resources :tags, only: [:index, :show, :update] do
  239. collection do
  240. post :approve_all
  241. post :reject_all
  242. post :batch
  243. end
  244. end
  245. end
  246. get '/admin', to: redirect('/admin/dashboard', status: 302)
  247. namespace :api do
  248. # OEmbed
  249. get '/oembed', to: 'oembed#show', as: :oembed
  250. # Identity proofs
  251. get :proofs, to: 'proofs#index'
  252. # JSON / REST API
  253. namespace :v1 do
  254. resources :statuses, only: [:create, :show, :destroy] do
  255. scope module: :statuses do
  256. resources :reblogged_by, controller: :reblogged_by_accounts, only: :index
  257. resources :favourited_by, controller: :favourited_by_accounts, only: :index
  258. resource :reblog, only: :create
  259. post :unreblog, to: 'reblogs#destroy'
  260. resource :favourite, only: :create
  261. post :unfavourite, to: 'favourites#destroy'
  262. resource :bookmark, only: :create
  263. post :unbookmark, to: 'bookmarks#destroy'
  264. resource :mute, only: :create
  265. post :unmute, to: 'mutes#destroy'
  266. resource :pin, only: :create
  267. post :unpin, to: 'pins#destroy'
  268. end
  269. member do
  270. get :context
  271. end
  272. end
  273. namespace :timelines do
  274. resource :home, only: :show, controller: :home
  275. resource :public, only: :show, controller: :public
  276. resources :tag, only: :show
  277. resources :list, only: :show
  278. end
  279. resources :streaming, only: [:index]
  280. resources :custom_emojis, only: [:index]
  281. resources :suggestions, only: [:index, :destroy]
  282. resources :scheduled_statuses, only: [:index, :show, :update, :destroy]
  283. resources :preferences, only: [:index]
  284. resources :announcements, only: [:index] do
  285. scope module: :announcements do
  286. resources :reactions, only: [:update, :destroy]
  287. end
  288. member do
  289. post :dismiss
  290. end
  291. end
  292. # namespace :crypto do
  293. # resources :deliveries, only: :create
  294. # namespace :keys do
  295. # resource :upload, only: [:create]
  296. # resource :query, only: [:create]
  297. # resource :claim, only: [:create]
  298. # resource :count, only: [:show]
  299. # end
  300. # resources :encrypted_messages, only: [:index] do
  301. # collection do
  302. # post :clear
  303. # end
  304. # end
  305. # end
  306. resources :conversations, only: [:index, :destroy] do
  307. member do
  308. post :read
  309. end
  310. end
  311. resources :media, only: [:create, :update, :show]
  312. resources :blocks, only: [:index]
  313. resources :mutes, only: [:index]
  314. resources :favourites, only: [:index]
  315. resources :bookmarks, only: [:index]
  316. resources :reports, only: [:create]
  317. resources :trends, only: [:index]
  318. resources :filters, only: [:index, :create, :show, :update, :destroy]
  319. resources :endorsements, only: [:index]
  320. resources :markers, only: [:index, :create]
  321. namespace :apps do
  322. get :verify_credentials, to: 'credentials#show'
  323. end
  324. resources :apps, only: [:create]
  325. namespace :emails do
  326. resources :confirmations, only: [:create]
  327. end
  328. resource :instance, only: [:show] do
  329. resources :peers, only: [:index], controller: 'instances/peers'
  330. resource :activity, only: [:show], controller: 'instances/activity'
  331. resources :rules, only: [:index], controller: 'instances/rules'
  332. end
  333. resource :domain_blocks, only: [:show, :create, :destroy]
  334. resource :directory, only: [:show]
  335. resources :follow_requests, only: [:index] do
  336. member do
  337. post :authorize
  338. post :reject
  339. end
  340. end
  341. resources :notifications, only: [:index, :show] do
  342. collection do
  343. post :clear
  344. end
  345. member do
  346. post :dismiss
  347. end
  348. end
  349. namespace :accounts do
  350. get :verify_credentials, to: 'credentials#show'
  351. patch :update_credentials, to: 'credentials#update'
  352. resource :search, only: :show, controller: :search
  353. resource :lookup, only: :show, controller: :lookup
  354. resources :relationships, only: :index
  355. end
  356. resources :accounts, only: [:create, :show] do
  357. resources :statuses, only: :index, controller: 'accounts/statuses'
  358. resources :followers, only: :index, controller: 'accounts/follower_accounts'
  359. resources :following, only: :index, controller: 'accounts/following_accounts'
  360. resources :lists, only: :index, controller: 'accounts/lists'
  361. resources :identity_proofs, only: :index, controller: 'accounts/identity_proofs'
  362. resources :featured_tags, only: :index, controller: 'accounts/featured_tags'
  363. member do
  364. post :follow
  365. post :unfollow
  366. post :block
  367. post :unblock
  368. post :mute
  369. post :unmute
  370. end
  371. resource :pin, only: :create, controller: 'accounts/pins'
  372. post :unpin, to: 'accounts/pins#destroy'
  373. resource :note, only: :create, controller: 'accounts/notes'
  374. end
  375. resources :lists, only: [:index, :create, :show, :update, :destroy] do
  376. resource :accounts, only: [:show, :create, :destroy], controller: 'lists/accounts'
  377. end
  378. namespace :featured_tags do
  379. get :suggestions, to: 'suggestions#index'
  380. end
  381. resources :featured_tags, only: [:index, :create, :destroy]
  382. resources :polls, only: [:create, :show] do
  383. resources :votes, only: :create, controller: 'polls/votes'
  384. end
  385. namespace :push do
  386. resource :subscription, only: [:create, :show, :update, :destroy]
  387. end
  388. namespace :admin do
  389. resources :accounts, only: [:index, :show, :destroy] do
  390. member do
  391. post :enable
  392. post :unsensitive
  393. post :unsilence
  394. post :unsuspend
  395. post :approve
  396. post :reject
  397. end
  398. resource :action, only: [:create], controller: 'account_actions'
  399. end
  400. resources :reports, only: [:index, :show] do
  401. member do
  402. post :assign_to_self
  403. post :unassign
  404. post :reopen
  405. post :resolve
  406. end
  407. end
  408. end
  409. end
  410. namespace :v2 do
  411. resources :media, only: [:create]
  412. get '/search', to: 'search#index', as: :search
  413. resources :suggestions, only: [:index]
  414. end
  415. namespace :web do
  416. resource :settings, only: [:update]
  417. resource :embed, only: [:create]
  418. resources :push_subscriptions, only: [:create] do
  419. member do
  420. put :update
  421. end
  422. end
  423. end
  424. end
  425. get '/web/(*any)', to: 'home#index', as: :web
  426. get '/about', to: 'about#show'
  427. get '/about/more', to: 'about#more'
  428. get '/terms', to: 'about#terms'
  429. get '/jump/:destin/(*path)', to: 'about#jump', :constraints => { :destin => /[0-9a-zA-Z\._-]+/ }, :format => 'html'
  430. get '/my_data/:year', to: 'about#my_data'
  431. match '/', via: [:post, :put, :patch, :delete], to: 'application#raise_not_found', format: false
  432. match '*unmatched_route', via: :all, to: 'application#raise_not_found', format: false
  433. end