Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Register
Sign in
Toggle navigation
Menu
Open sidebar
Tiger Ton
mastodon
Commits
91634947
Commit
91634947
authored
6 years ago
by
ThibG
Committed by
Eugen Rochko
6 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Explicitly disable storage of REST API results (#10655)
Fixes #10652
parent
011b0323
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
app/controllers/api/base_controller.rb
+6
-0
app/controllers/api/base_controller.rb
app/controllers/api/v1/custom_emojis_controller.rb
+2
-0
app/controllers/api/v1/custom_emojis_controller.rb
app/controllers/api/v1/instances/activity_controller.rb
+1
-0
app/controllers/api/v1/instances/activity_controller.rb
app/controllers/api/v1/instances/peers_controller.rb
+1
-0
app/controllers/api/v1/instances/peers_controller.rb
app/controllers/api/v1/instances_controller.rb
+1
-0
app/controllers/api/v1/instances_controller.rb
with
11 additions
and
0 deletions
+11
-0
app/controllers/api/base_controller.rb
+
6
-
0
View file @
91634947
...
...
@@ -9,6 +9,8 @@ class Api::BaseController < ApplicationController
skip_before_action
:store_current_location
skip_before_action
:check_user_permissions
before_action
:set_cache_headers
protect_from_forgery
with: :null_session
rescue_from
ActiveRecord
::
RecordInvalid
,
Mastodon
::
ValidationError
do
|
e
|
...
...
@@ -88,4 +90,8 @@ class Api::BaseController < ApplicationController
def
authorize_if_got_token!
(
*
scopes
)
doorkeeper_authorize!
(
*
scopes
)
if
doorkeeper_token
end
def
set_cache_headers
response
.
headers
[
'Cache-Control'
]
=
'no-cache, no-store, max-age=0, must-revalidate'
end
end
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/custom_emojis_controller.rb
+
2
-
0
View file @
91634947
...
...
@@ -3,6 +3,8 @@
class
Api::V1::CustomEmojisController
<
Api
::
BaseController
respond_to
:json
skip_before_action
:set_cache_headers
def
index
render_cached_json
(
'api:v1:custom_emojis'
,
expires_in:
1
.
minute
)
do
ActiveModelSerializers
::
SerializableResource
.
new
(
CustomEmoji
.
local
.
where
(
disabled:
false
),
each_serializer:
REST
::
CustomEmojiSerializer
)
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/instances/activity_controller.rb
+
1
-
0
View file @
91634947
...
...
@@ -2,6 +2,7 @@
class
Api::V1::Instances::ActivityController
<
Api
::
BaseController
before_action
:require_enabled_api!
skip_before_action
:set_cache_headers
respond_to
:json
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/instances/peers_controller.rb
+
1
-
0
View file @
91634947
...
...
@@ -2,6 +2,7 @@
class
Api::V1::Instances::PeersController
<
Api
::
BaseController
before_action
:require_enabled_api!
skip_before_action
:set_cache_headers
respond_to
:json
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/instances_controller.rb
+
1
-
0
View file @
91634947
...
...
@@ -2,6 +2,7 @@
class
Api::V1::InstancesController
<
Api
::
BaseController
respond_to
:json
skip_before_action
:set_cache_headers
def
show
render_cached_json
(
'api:v1:instances'
,
expires_in:
5
.
minutes
)
do
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets