Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-23 18:00:29 +01:00
DEV: Add logic to append tag if user allowed
Dieser Commit ist enthalten in:
Ursprung
a518955423
Commit
c29c3b084e
1 geänderte Dateien mit 93 neuen und 87 gelöschten Zeilen
|
@ -36,7 +36,7 @@ class CustomWizard::Action
|
||||||
end
|
end
|
||||||
|
|
||||||
if creates_post? && @result.success?
|
if creates_post? && @result.success?
|
||||||
@result.handler.enqueue_jobs
|
@result.handler.enqueue_jobs
|
||||||
end
|
end
|
||||||
|
|
||||||
if @result.success? && @result.output.present?
|
if @result.success? && @result.output.present?
|
||||||
|
@ -104,6 +104,7 @@ class CustomWizard::Action
|
||||||
end
|
end
|
||||||
|
|
||||||
params = basic_topic_params
|
params = basic_topic_params
|
||||||
|
params.delete(:tags) unless user_can_tag
|
||||||
|
|
||||||
targets = CustomWizard::Mapper.new(
|
targets = CustomWizard::Mapper.new(
|
||||||
inputs: action['recipient'],
|
inputs: action['recipient'],
|
||||||
|
@ -610,6 +611,10 @@ class CustomWizard::Action
|
||||||
user: user
|
user: user
|
||||||
).perform
|
).perform
|
||||||
|
|
||||||
|
if tags = action_tags
|
||||||
|
params[:tags] = tags
|
||||||
|
end
|
||||||
|
|
||||||
params[:raw] = action['post_builder'] ?
|
params[:raw] = action['post_builder'] ?
|
||||||
mapper.interpolate(
|
mapper.interpolate(
|
||||||
action['post_template'],
|
action['post_template'],
|
||||||
|
@ -632,10 +637,6 @@ class CustomWizard::Action
|
||||||
params[:category] = category
|
params[:category] = category
|
||||||
end
|
end
|
||||||
|
|
||||||
if tags = action_tags
|
|
||||||
params[:tags] = tags
|
|
||||||
end
|
|
||||||
|
|
||||||
if public_topic_fields.any?
|
if public_topic_fields.any?
|
||||||
public_topic_fields.each do |field|
|
public_topic_fields.each do |field|
|
||||||
unless action[field].nil? || action[field] == ""
|
unless action[field].nil? || action[field] == ""
|
||||||
|
@ -674,7 +675,7 @@ class CustomWizard::Action
|
||||||
end
|
end
|
||||||
|
|
||||||
if attr === "full_name" && input.blank?
|
if attr === "full_name" && input.blank?
|
||||||
input = action["name"]
|
input = action["name"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if input.present?
|
if input.present?
|
||||||
|
@ -767,7 +768,7 @@ class CustomWizard::Action
|
||||||
"#{key}_upload_url"
|
"#{key}_upload_url"
|
||||||
else
|
else
|
||||||
key
|
key
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def cast_profile_value(value, key)
|
def cast_profile_value(value, key)
|
||||||
|
@ -837,4 +838,9 @@ class CustomWizard::Action
|
||||||
@log.join('; ')
|
@log.join('; ')
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
def user_can_tag
|
||||||
|
allowed_groups =
|
||||||
|
SiteSetting.pm_tags_allowed_for_groups.split('|').map(&:to_i)
|
||||||
|
user.groups.pluck(:id).any? { |group| allowed_groups.include?(group) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Laden …
In neuem Issue referenzieren