mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 01:24:48 +08:00
FIX: Include permissions in the tag serializer (#27849)
The 'permissions' field is used by the composer and the category chooser to render the category.
This commit is contained in:
@ -243,6 +243,18 @@ class Tag < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def all_category_ids
|
||||
@all_category_ids ||=
|
||||
categories.pluck(:id) +
|
||||
tag_groups.includes(:categories).flat_map { |tg| tg.categories.map(&:id) }
|
||||
end
|
||||
|
||||
def all_categories(guardian)
|
||||
categories = Category.secured(guardian).where(id: all_category_ids)
|
||||
Category.preload_user_fields!(guardian, categories)
|
||||
categories
|
||||
end
|
||||
|
||||
%i[tag_created tag_updated tag_destroyed].each do |event|
|
||||
define_method("trigger_#{event}_event") do
|
||||
DiscourseEvent.trigger(event, self)
|
||||
|
Reference in New Issue
Block a user