mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: stop memoize PostActionTypes (#28005)
Memoizing all_flags on PostActionType was a mistake. This commit brings back the cache on the serialize level.
This commit is contained in:
committed by
GitHub
parent
5105fce899
commit
fb7cc2d375
@@ -290,7 +290,10 @@ class PostSerializer < BasicPostSerializer
|
||||
result = []
|
||||
can_see_post = scope.can_see_post?(object)
|
||||
|
||||
PostActionType.types.each do |sym, id|
|
||||
public_flag_types =
|
||||
(@topic_view.present? ? @topic_view.public_flag_types : PostActionType.public_types)
|
||||
|
||||
(@topic_view.present? ? @topic_view.flag_types : PostActionType.types).each do |sym, id|
|
||||
count_col = "#{sym}_count".to_sym
|
||||
|
||||
count = object.public_send(count_col) if object.respond_to?(count_col)
|
||||
@@ -301,6 +304,22 @@ class PostSerializer < BasicPostSerializer
|
||||
sym,
|
||||
opts: {
|
||||
taken_actions: actions,
|
||||
notify_flag_types:
|
||||
(
|
||||
if @topic_view.present?
|
||||
@topic_view.notify_flag_types
|
||||
else
|
||||
PostActionType.notify_flag_types
|
||||
end
|
||||
),
|
||||
additional_message_types:
|
||||
(
|
||||
if @topic_view.present?
|
||||
@topic_view.additional_message_types
|
||||
else
|
||||
PostActionType.additional_message_types
|
||||
end
|
||||
),
|
||||
},
|
||||
can_see_post: can_see_post,
|
||||
)
|
||||
@@ -327,7 +346,7 @@ class PostSerializer < BasicPostSerializer
|
||||
end
|
||||
|
||||
# only show public data
|
||||
unless scope.is_staff? || PostActionType.public_types.values.include?(id)
|
||||
unless scope.is_staff? || public_flag_types.values.include?(id)
|
||||
summary[:count] = summary[:acted] ? 1 : 0
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user