routes.rb 8.28 KB
Newer Older
1 2
# frozen_string_literal: true

danielgrippi's avatar
danielgrippi committed
3
#   Copyright (c) 2010-2011, Diaspora Inc.  This file is
Raphael's avatar
Raphael committed
4
#   licensed under the Affero General Public License version 3 or later.  See
Raphael's avatar
Raphael committed
5
#   the COPYRIGHT file.
6

7
require "sidekiq/web"
Senya's avatar
Senya committed
8
require "sidekiq/cron/web"
9
Sidekiq::Web.set :sessions, false # disable rack session cookie
Jonne Haß's avatar
Jonne Haß committed
10

Benjamin Neff's avatar
Benjamin Neff committed
11 12
Rails.application.routes.draw do
  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
Lukas Matt's avatar
Lukas Matt committed
13

Denys Kurets's avatar
Denys Kurets committed
14
  resources :report, except: %i(edit new show)
Lukas Matt's avatar
Lukas Matt committed
15

Jonne Haß's avatar
Jonne Haß committed
16 17 18 19
  constraints ->(req) { req.env["warden"].authenticate?(scope: :user) &&
                        req.env['warden'].user.admin? } do
    mount Sidekiq::Web => '/sidekiq', :as => 'sidekiq'
  end
danielgrippi's avatar
danielgrippi committed
20

21
  # Federation
22 23
  mount DiasporaFederation::Engine => "/"

24
  get "/atom.xml" => redirect('http://blog.diasporafoundation.org/feed/atom') #too many stupid redirects :()
Florian Staudacher's avatar
Florian Staudacher committed
25

Maxwell Salzberg's avatar
Maxwell Salzberg committed
26
  get 'oembed' => 'posts#oembed', :as => 'oembed'
MrZYX's avatar
MrZYX committed
27
  # Posting and Reading
Denys Kurets's avatar
Denys Kurets committed
28
  resources :reshares, only: %i(create)
Maxwell Salzberg's avatar
Maxwell Salzberg committed
29

MrZYX's avatar
MrZYX committed
30
  resources :status_messages, :only => [:new, :create]
Raphael Sofaer's avatar
Raphael Sofaer committed
31

Denys Kurets's avatar
Denys Kurets committed
32
  resources :posts, only: %i(show destroy) do
33
    member do
34
      get :mentionable
35
    end
36

37 38 39 40
    resource :participation, only: %i(create destroy)
    resources :poll_participations, only: :create
    resources :likes, only: %i(create destroy index)
    resources :comments, only: %i(new create destroy index)
41
    resources :reshares, only: :index
42
  end
Dennis Collinson's avatar
Dennis Collinson committed
43

44
  get 'p/:id' => 'posts#show', :as => 'short_post'
45

46 47 48 49 50
  # roll up likes into a nested resource above
  resources :comments, :only => [:create, :destroy] do
    resources :likes, :only => [:create, :destroy, :index]
  end

51
  # Streams
52 53
  get "activity" => "streams#activity", :as => "activity_stream"
  get "stream" => "streams#multi", :as => "stream"
54 55 56 57 58 59
  get "public" => "streams#public", :as => "public_stream"
  get "followed_tags" => "streams#followed_tags", :as => "followed_tags_stream"
  get "mentions" => "streams#mentioned", :as => "mentioned_stream"
  get "liked" => "streams#liked", :as => "liked_stream"
  get "commented" => "streams#commented", :as => "commented_stream"
  get "aspects" => "streams#aspects", :as => "aspects_stream"
Florian Staudacher's avatar
Florian Staudacher committed
60

Denys Kurets's avatar
Denys Kurets committed
61
  resources :aspects, except: %i(index new edit) do
62
    put :toggle_chat_privilege
63 64 65
    collection do
      put "order" => :update_order
    end
66
  end
67

68
  get 'bookmarklet' => 'status_messages#bookmarklet'
69

Denys Kurets's avatar
Denys Kurets committed
70
  resources :photos, only: %i(destroy create) do
MrZYX's avatar
MrZYX committed
71
    put :make_profile_photo
72
  end
73

74 75
	#Search
	get 'search' => "search#search"
76

Senya's avatar
Senya committed
77 78
  get "link" => "links#resolve"

Denys Kurets's avatar
Denys Kurets committed
79 80
  resources :conversations, except: %i(edit update destroy)  do
    resources :messages, only: %i(create)
MrZYX's avatar
MrZYX committed
81
    delete 'visibility' => 'conversation_visibilities#destroy'
82
    get "raw"
83
  end
84

MrZYX's avatar
MrZYX committed
85
  resources :notifications, :only => [:index, :update] do
86 87 88
    collection do
      get :read_all
    end
89
  end
90

91

MrZYX's avatar
MrZYX committed
92
  resources :tags, :only => [:index]
93

94 95 96 97 98
  resources "tag_followings", only: %i(create destroy index) do
    collection do
      get :manage
    end
  end
99

MrZYX's avatar
MrZYX committed
100
  get 'tags/:name' => 'tags#show', :as => 'tag'
101

MrZYX's avatar
MrZYX committed
102
  # Users and people
103

104 105
  resource :user, only: %i(edit destroy), shallow: true do
    put :edit, action: :update
106
    post :export_profile
107
    get :download_profile
108
    post :export_photos
109
    get :download_photos
110
    post :auth_token
MrZYX's avatar
MrZYX committed
111 112 113
  end

  controller :users do
114 115 116 117 118 119
    get "public/:username"          => :public,                  :as => :users_public
    get "getting_started"           => :getting_started,         :as => :getting_started
    get "confirm_email/:token"      => :confirm_email,           :as => :confirm_email
    get "privacy"                   => :privacy_settings,        :as => :privacy_settings
    put "privacy"                   => :update_privacy_settings, :as => :update_privacy_settings
    get "getting_started_completed" => :getting_started_completed
MrZYX's avatar
MrZYX committed
120
  end
121

lislis's avatar
lislis committed
122 123 124 125 126 127
  resource :two_factor_authentication, only: %i[show create destroy] do
    get :confirm, action: :confirm_2fa
    post :confirm, action: :confirm_and_activate_2fa
    get :recovery_codes
  end

128 129 130 131 132
  devise_for :users, controllers: {sessions: :sessions}, skip: :registration
  devise_scope :user do
    get "/users/sign_up" => "registrations#new",    :as => :new_user_registration
    post "/users"        => "registrations#create", :as => :user_registration
  end
133

134 135
  get "users/invitations"  => "invitations#new",    :as => "new_user_invitation"
  post "users/invitations" => "invitations#create", :as => "user_invitation"
Florian Staudacher's avatar
Florian Staudacher committed
136

MrZYX's avatar
MrZYX committed
137
  get 'login' => redirect('/users/sign_in')
138

139 140
  # Admin backend routes

141
  scope "admins", controller: :admins do
Jonne Haß's avatar
Jonne Haß committed
142
    match :user_search, via: [:get, :post]
143 144 145 146 147
    get :admin_inviter
    get :weekly_user_stats
    get :stats, as: "pod_stats"
    get :dashboard, as: "admin_dashboard"
    get "add_invites/:invite_code_id" => "admins#add_invites", :as => "add_invites"
MrZYX's avatar
MrZYX committed
148
  end
149

150
  namespace :admin do
151 152 153 154
    resources :pods, only: :index do
      post :recheck
    end

155
    post 'users/:id/close_account' => 'users#close_account', :as => 'close_account'
Akash Agrawall's avatar
Akash Agrawall committed
156 157
    post 'users/:id/lock_account' => 'users#lock_account', :as => 'lock_account'
    post 'users/:id/unlock_account' => 'users#unlock_account', :as => 'unlock_account'
158 159 160 161 162 163
    post 'users/:id/make_admin' => 'users#make_admin', :as => 'make_admin'
    post 'users/:id/remove_admin' => 'users#remove_admin', :as => 'remove_admin'
    post 'users/:id/make_moderator' => 'users#make_moderator', :as => 'make_moderator'
    post 'users/:id/remove_moderator' => 'users#remove_moderator', :as => 'remove_moderator'
    post 'users/:id/make_spotlight' => 'users#make_spotlight', :as => 'make_spotlight'
    post 'users/:id/remove_spotlight' => 'users#remove_spotlight', :as => 'remove_spotlight'
164 165
  end

166
  resource :profile, :only => [:edit, :update]
167 168
  resources :profiles, :only => [:show]

169

Denys Kurets's avatar
Denys Kurets committed
170
  resources :contacts, only: %i(index)
171
  resources :aspect_memberships, :only  => [:destroy, :create]
172 173
  resources :share_visibilities,  :only => [:update]
  resources :blocks, :only => [:create, :destroy]
MrZYX's avatar
MrZYX committed
174

175
  get 'i/:id' => 'invitation_codes#show', :as => 'invite_code'
176

177
  get 'people/refresh_search' => "people#refresh_search"
Denys Kurets's avatar
Denys Kurets committed
178 179 180
  resources :people, only: %i(show index) do
    resources :status_messages, only: %i(new create)
    resources :photos, except:  %i(new update)
181
    get :stream
Florian Staudacher's avatar
Florian Staudacher committed
182
    get :hovercard
183

MrZYX's avatar
d'oh  
MrZYX committed
184 185 186
    collection do
      post 'by_handle' => :retrieve_remote, :as => 'person_by_handle'
    end
187
  end
188
  get '/u/:username' => 'people#show', :as => 'user_profile', :constraints => { :username => /[^\/]+/ }
189

MrZYX's avatar
MrZYX committed
190 191 192 193
  # External

  resources :services, :only => [:index, :destroy]
  controller :services do
MrZYX's avatar
MrZYX committed
194
    scope "/auth", :as => "auth" do
Jonne Haß's avatar
Jonne Haß committed
195 196
      get ':provider/callback' => :create
      get :failure
MrZYX's avatar
MrZYX committed
197
    end
MrZYX's avatar
MrZYX committed
198 199
  end

200
  get 'community_spotlight' => "contacts#spotlight", :as => 'community_spotlight'
MrZYX's avatar
MrZYX committed
201 202
  # Mobile site

203
  get 'mobile/toggle', :to => 'home#toggle_mobile', :as => 'toggle_mobile'
augier's avatar
augier committed
204
  get "/m", to: "home#force_mobile", as: "force_mobile"
MrZYX's avatar
MrZYX committed
205

Jonne Haß's avatar
Jonne Haß committed
206
  # Help
207
  get 'help' => 'help#faq', :as => 'help'
208
  get "help/registration_closed" => "help#registration_closed", :as => "registration_closed"
209
  get 'help/:topic' => 'help#faq'
Steffen van Bergerem's avatar
Steffen van Bergerem committed
210

211
  #Protocol Url
Jonne Haß's avatar
Jonne Haß committed
212
  get 'protocol' => redirect("http://wiki.diasporafoundation.org/Federation_Protocol_Overview")
213

Jonne Haß's avatar
Jonne Haß committed
214 215 216
  # NodeInfo
  get ".well-known/nodeinfo", to: "node_info#jrd"
  get "nodeinfo/:version",    to: "node_info#document", as: "node_info", constraints: {version: /\d+\.\d+/}
217
  get "statistics",           to: "node_info#statistics"
218

219
  # Terms
220
  if AppConfig.settings.terms.enable? || Rails.env.test?
221 222
    get 'terms' => 'terms#index'
  end
223

224 225 226
  # Relay
  get ".well-known/x-social-relay" => "social_relay#well_known"

227
  # Startpage
228
  root :to => 'home#show'
229
  get "podmin", to: "home#podmin"
augier's avatar
augier committed
230

Kent Shikama's avatar
Kent Shikama committed
231 232 233
  namespace :api do
    namespace :openid_connect do
      resources :clients, only: :create
Kent Shikama's avatar
Kent Shikama committed
234 235
      get "clients/find", to: "clients#find"

Kent Shikama's avatar
Kent Shikama committed
236
      post "access_tokens", to: "token_endpoint#create"
Kent Shikama's avatar
Kent Shikama committed
237 238 239

      # Authorization Servers MUST support the use of the HTTP GET and POST methods at the Authorization Endpoint
      # See http://openid.net/specs/openid-connect-core-1_0.html#AuthResponseValidation
augier's avatar
augier committed
240
      resources :authorizations, only: %i(new create destroy)
Kent Shikama's avatar
Kent Shikama committed
241
      post "authorizations/new", to: "authorizations#new"
augier's avatar
augier committed
242
      get "user_applications", to: "user_applications#index"
Kent Shikama's avatar
Kent Shikama committed
243
      get "jwks.json", to: "id_tokens#jwks"
244
      match "user_info", to: "user_info#show", via: %i(get post)
Kent Shikama's avatar
Kent Shikama committed
245 246
    end
  end
augier's avatar
augier committed
247

Kent Shikama's avatar
Kent Shikama committed
248
  get ".well-known/openid-configuration", to: "api/openid_connect/discovery#configuration"
Fla's avatar
Fla committed
249
  get "manifest.json", to: "manifest#show"
Raphael Sofaer's avatar
Raphael Sofaer committed
250
end