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.

522 lines
16 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 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
8 years ago
  1. # frozen_string_literal: true
  2. require 'sidekiq_unique_jobs/web'
  3. require 'sidekiq-scheduler/web'
  4. Sidekiq::Web.set :session_secret, Rails.application.secrets[:secret_key_base]
  5. Rails.application.routes.draw do
  6. root 'home#index'
  7. mount LetterOpenerWeb::Engine, at: 'letter_opener' if Rails.env.development?
  8. health_check_routes
  9. authenticate :user, lambda { |u| u.admin? } do
  10. mount Sidekiq::Web, at: 'sidekiq', as: :sidekiq
  11. mount PgHero::Engine, at: 'pghero', as: :pghero
  12. end
  13. use_doorkeeper do
  14. controllers authorizations: 'oauth/authorizations',
  15. authorized_applications: 'oauth/authorized_applications',
  16. tokens: 'oauth/tokens'
  17. end
  18. get '.well-known/host-meta', to: 'well_known/host_meta#show', as: :host_meta, defaults: { format: 'xml' }
  19. get '.well-known/nodeinfo', to: 'well_known/nodeinfo#index', as: :nodeinfo, defaults: { format: 'json' }
  20. get '.well-known/webfinger', to: 'well_known/webfinger#show', as: :webfinger
  21. get '.well-known/change-password', to: redirect('/auth/edit')
  22. get '.well-known/keybase-proof-config', to: 'well_known/keybase_proof_config#show'
  23. get '/nodeinfo/2.0', to: 'well_known/nodeinfo#show', as: :nodeinfo_schema
  24. get 'manifest', to: 'manifests#show', defaults: { format: 'json' }
  25. get 'intent', to: 'intents#show'
  26. get 'custom.css', to: 'custom_css#show', as: :custom_css
  27. resource :instance_actor, path: 'actor', only: [:show] do
  28. resource :inbox, only: [:create], module: :activitypub
  29. resource :outbox, only: [:show], module: :activitypub
  30. end
  31. devise_scope :user do
  32. get '/invite/:invite_code', to: 'auth/registrations#new', as: :public_invite
  33. namespace :auth do
  34. resource :setup, only: [:show, :update], controller: :setup
  35. resource :challenge, only: [:create], controller: :challenges
  36. get 'sessions/security_key_options', to: 'sessions#webauthn_options'
  37. end
  38. end
  39. devise_for :users, path: 'auth', controllers: {
  40. omniauth_callbacks: 'auth/omniauth_callbacks',
  41. sessions: 'auth/sessions',
  42. registrations: 'auth/registrations',
  43. passwords: 'auth/passwords',
  44. confirmations: 'auth/confirmations',
  45. }
  46. get '/users/:username', to: redirect('/@%{username}'), constraints: lambda { |req| req.format.nil? || req.format.html? }
  47. get '/authorize_follow', to: redirect { |_, request| "/authorize_interaction?#{request.params.to_query}" }
  48. resources :accounts, path: 'users', only: [:show], param: :username do
  49. get :remote_follow, to: 'remote_follow#new'
  50. post :remote_follow, to: 'remote_follow#create'
  51. resources :statuses, only: [:show] do
  52. member do
  53. get :activity
  54. get :embed
  55. end
  56. resources :replies, only: [:index], module: :activitypub
  57. end
  58. resources :followers, only: [:index], controller: :follower_accounts
  59. resources :following, only: [:index], controller: :following_accounts
  60. resource :follow, only: [:create], controller: :account_follow
  61. resource :unfollow, only: [:create], controller: :account_unfollow
  62. resource :outbox, only: [:show], module: :activitypub
  63. resource :inbox, only: [:create], module: :activitypub
  64. resource :claim, only: [:create], module: :activitypub
  65. resources :collections, 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 '/explore/:id', to: 'directories#show', as: :explore_hashtag
  78. get '/settings', to: redirect('/settings/profile')
  79. namespace :settings do
  80. resource :profile, only: [:show, :update] do
  81. resources :pictures, only: :destroy
  82. end
  83. get :preferences, to: redirect('/settings/preferences/appearance')
  84. namespace :preferences do
  85. resource :appearance, only: [:show, :update], controller: :appearance
  86. resource :notifications, only: [:show, :update]
  87. resource :other, only: [:show, :update], controller: :other
  88. end
  89. resource :import, only: [:show, :create]
  90. resource :export, only: [:show, :create]
  91. namespace :exports, constraints: { format: :csv } do
  92. resources :follows, only: :index, controller: :following_accounts
  93. resources :blocks, only: :index, controller: :blocked_accounts
  94. resources :mutes, only: :index, controller: :muted_accounts
  95. resources :lists, only: :index, controller: :lists
  96. resources :domain_blocks, only: :index, controller: :blocked_domains
  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: /[^\/]+/ }
  169. resources :reports, only: [:index, :show] do
  170. member do
  171. post :assign_to_self
  172. post :unassign
  173. post :reopen
  174. post :resolve
  175. end
  176. resources :reported_statuses, only: [:create]
  177. end
  178. resources :report_notes, only: [:create, :destroy]
  179. resources :accounts, only: [:index, :show, :destroy] do
  180. member do
  181. post :enable
  182. post :unsilence
  183. post :unsuspend
  184. post :redownload
  185. post :remove_avatar
  186. post :remove_header
  187. post :memorialize
  188. post :approve
  189. post :reject
  190. end
  191. resource :change_email, only: [:show, :update]
  192. resource :reset, only: [:create]
  193. resource :action, only: [:new, :create], controller: 'account_actions'
  194. resources :statuses, only: [:index, :show, :create, :update, :destroy]
  195. resources :relationships, only: [:index]
  196. resource :confirmation, only: [:create] do
  197. collection do
  198. post :resend
  199. end
  200. end
  201. resource :role, only: [] do
  202. member do
  203. post :promote
  204. post :demote
  205. end
  206. end
  207. end
  208. resources :pending_accounts, only: [:index] do
  209. collection do
  210. post :approve_all
  211. post :reject_all
  212. post :batch
  213. end
  214. end
  215. resources :users, only: [] do
  216. resource :two_factor_authentication, only: [:destroy]
  217. end
  218. resources :custom_emojis, only: [:index, :new, :create] do
  219. collection do
  220. post :batch
  221. end
  222. end
  223. resources :ip_blocks, only: [:index, :new, :create] do
  224. collection do
  225. post :batch
  226. end
  227. end
  228. resources :account_moderation_notes, only: [:create, :destroy]
  229. resources :tags, only: [:index, :show, :update] do
  230. collection do
  231. post :approve_all
  232. post :reject_all
  233. post :batch
  234. end
  235. end
  236. end
  237. get '/admin', to: redirect('/admin/dashboard', status: 302)
  238. namespace :api do
  239. # OEmbed
  240. get '/oembed', to: 'oembed#show', as: :oembed
  241. # Identity proofs
  242. get :proofs, to: 'proofs#index'
  243. # JSON / REST API
  244. namespace :v1 do
  245. resources :statuses, only: [:create, :show, :destroy] do
  246. scope module: :statuses do
  247. resources :reblogged_by, controller: :reblogged_by_accounts, only: :index
  248. resources :favourited_by, controller: :favourited_by_accounts, only: :index
  249. resource :reblog, only: :create
  250. post :unreblog, to: 'reblogs#destroy'
  251. resource :favourite, only: :create
  252. post :unfavourite, to: 'favourites#destroy'
  253. resource :bookmark, only: :create
  254. post :unbookmark, to: 'bookmarks#destroy'
  255. resource :mute, only: :create
  256. post :unmute, to: 'mutes#destroy'
  257. resource :pin, only: :create
  258. post :unpin, to: 'pins#destroy'
  259. end
  260. member do
  261. get :context
  262. end
  263. end
  264. namespace :timelines do
  265. resource :home, only: :show, controller: :home
  266. resource :public, only: :show, controller: :public
  267. resources :tag, only: :show
  268. resources :list, only: :show
  269. end
  270. resources :streaming, only: [:index]
  271. resources :custom_emojis, only: [:index]
  272. resources :suggestions, only: [:index, :destroy]
  273. resources :scheduled_statuses, only: [:index, :show, :update, :destroy]
  274. resources :preferences, only: [:index]
  275. resources :announcements, only: [:index] do
  276. scope module: :announcements do
  277. resources :reactions, only: [:update, :destroy]
  278. end
  279. member do
  280. post :dismiss
  281. end
  282. end
  283. # namespace :crypto do
  284. # resources :deliveries, only: :create
  285. # namespace :keys do
  286. # resource :upload, only: [:create]
  287. # resource :query, only: [:create]
  288. # resource :claim, only: [:create]
  289. # resource :count, only: [:show]
  290. # end
  291. # resources :encrypted_messages, only: [:index] do
  292. # collection do
  293. # post :clear
  294. # end
  295. # end
  296. # end
  297. resources :conversations, only: [:index, :destroy] do
  298. member do
  299. post :read
  300. end
  301. end
  302. resources :media, only: [:create, :update, :show]
  303. resources :blocks, only: [:index]
  304. resources :mutes, only: [:index]
  305. resources :favourites, only: [:index]
  306. resources :bookmarks, only: [:index]
  307. resources :reports, only: [:create]
  308. resources :trends, only: [:index]
  309. resources :filters, only: [:index, :create, :show, :update, :destroy]
  310. resources :endorsements, only: [:index]
  311. resources :markers, only: [:index, :create]
  312. namespace :apps do
  313. get :verify_credentials, to: 'credentials#show'
  314. end
  315. resources :apps, only: [:create]
  316. resource :instance, only: [:show] do
  317. resources :peers, only: [:index], controller: 'instances/peers'
  318. resource :activity, only: [:show], controller: 'instances/activity'
  319. end
  320. resource :domain_blocks, only: [:show, :create, :destroy]
  321. resource :directory, only: [:show]
  322. resources :follow_requests, only: [:index] do
  323. member do
  324. post :authorize
  325. post :reject
  326. end
  327. end
  328. resources :notifications, only: [:index, :show] do
  329. collection do
  330. post :clear
  331. end
  332. member do
  333. post :dismiss
  334. end
  335. end
  336. namespace :accounts do
  337. get :verify_credentials, to: 'credentials#show'
  338. patch :update_credentials, to: 'credentials#update'
  339. resource :search, only: :show, controller: :search
  340. resources :relationships, only: :index
  341. end
  342. resources :accounts, only: [:create, :show] do
  343. resources :statuses, only: :index, controller: 'accounts/statuses'
  344. resources :followers, only: :index, controller: 'accounts/follower_accounts'
  345. resources :following, only: :index, controller: 'accounts/following_accounts'
  346. resources :lists, only: :index, controller: 'accounts/lists'
  347. resources :identity_proofs, only: :index, controller: 'accounts/identity_proofs'
  348. resources :featured_tags, only: :index, controller: 'accounts/featured_tags'
  349. member do
  350. post :follow
  351. post :unfollow
  352. post :block
  353. post :unblock
  354. post :mute
  355. post :unmute
  356. end
  357. resource :pin, only: :create, controller: 'accounts/pins'
  358. post :unpin, to: 'accounts/pins#destroy'
  359. resource :note, only: :create, controller: 'accounts/notes'
  360. end
  361. resources :lists, only: [:index, :create, :show, :update, :destroy] do
  362. resource :accounts, only: [:show, :create, :destroy], controller: 'lists/accounts'
  363. end
  364. namespace :featured_tags do
  365. get :suggestions, to: 'suggestions#index'
  366. end
  367. resources :featured_tags, only: [:index, :create, :destroy]
  368. resources :polls, only: [:create, :show] do
  369. resources :votes, only: :create, controller: 'polls/votes'
  370. end
  371. namespace :push do
  372. resource :subscription, only: [:create, :show, :update, :destroy]
  373. end
  374. namespace :admin do
  375. resources :accounts, only: [:index, :show, :destroy] do
  376. member do
  377. post :enable
  378. post :unsilence
  379. post :unsuspend
  380. post :approve
  381. post :reject
  382. end
  383. resource :action, only: [:create], controller: 'account_actions'
  384. end
  385. resources :reports, only: [:index, :show] do
  386. member do
  387. post :assign_to_self
  388. post :unassign
  389. post :reopen
  390. post :resolve
  391. end
  392. end
  393. end
  394. end
  395. namespace :v2 do
  396. resources :media, only: [:create]
  397. get '/search', to: 'search#index', as: :search
  398. end
  399. namespace :web do
  400. resource :settings, only: [:update]
  401. resource :embed, only: [:create]
  402. resources :push_subscriptions, only: [:create] do
  403. member do
  404. put :update
  405. end
  406. end
  407. end
  408. end
  409. get '/web/(*any)', to: 'home#index', as: :web
  410. get '/about', to: 'about#show'
  411. get '/about/more', to: 'about#more'
  412. get '/terms', to: 'about#terms'
  413. match '/', via: [:post, :put, :patch, :delete], to: 'application#raise_not_found', format: false
  414. match '*unmatched_route', via: :all, to: 'application#raise_not_found', format: false
  415. end