mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 00:32:52 +08:00
FEATURE: Add hidden site settings for discobot to skip certain tutorials
Hidden for now because I'm undecided on whether this should be an exposed interface.
This commit is contained in:
@ -6,6 +6,7 @@ en:
|
|||||||
discourse_narrative_bot_disable_public_replies: "Disable public replies by Discourse Narrative Bot"
|
discourse_narrative_bot_disable_public_replies: "Disable public replies by Discourse Narrative Bot"
|
||||||
discourse_narrative_bot_welcome_post_type: "Type of welcome post that the Discourse Narrative Bot should send out"
|
discourse_narrative_bot_welcome_post_type: "Type of welcome post that the Discourse Narrative Bot should send out"
|
||||||
discourse_narrative_bot_welcome_post_delay: "Wait (n) seconds before sending the Discourse Narrative Bot welcome post."
|
discourse_narrative_bot_welcome_post_delay: "Wait (n) seconds before sending the Discourse Narrative Bot welcome post."
|
||||||
|
discourse_narrative_bot_skip_tutorials: "Discourse Narrative Bot tutorials to skip"
|
||||||
|
|
||||||
badges:
|
badges:
|
||||||
certified:
|
certified:
|
||||||
|
@ -7,6 +7,10 @@ plugins:
|
|||||||
discourse_narrative_bot_welcome_post_type:
|
discourse_narrative_bot_welcome_post_type:
|
||||||
default: 'new_user_track'
|
default: 'new_user_track'
|
||||||
enum: 'DiscourseNarrativeBot::WelcomePostTypeSiteSetting'
|
enum: 'DiscourseNarrativeBot::WelcomePostTypeSiteSetting'
|
||||||
|
discourse_narrative_bot_skip_tutorials:
|
||||||
|
default: ''
|
||||||
|
type: list
|
||||||
|
hidden: true
|
||||||
discourse_narrative_bot_welcome_post_delay:
|
discourse_narrative_bot_welcome_post_delay:
|
||||||
default: 0
|
default: 0
|
||||||
discourse_narrative_bot_ignored_usernames:
|
discourse_narrative_bot_ignored_usernames:
|
||||||
|
@ -30,7 +30,12 @@ module DiscourseNarrativeBot
|
|||||||
next_opts = self.class::TRANSITION_TABLE.fetch(next_state)
|
next_opts = self.class::TRANSITION_TABLE.fetch(next_state)
|
||||||
prerequisite = next_opts[:prerequisite]
|
prerequisite = next_opts[:prerequisite]
|
||||||
|
|
||||||
break if !prerequisite || instance_eval(&prerequisite)
|
if (!prerequisite || instance_eval(&prerequisite)) && !(
|
||||||
|
SiteSetting.discourse_narrative_bot_skip_tutorials.present? &&
|
||||||
|
SiteSetting.discourse_narrative_bot_skip_tutorials.split("|").include?(next_state.to_s))
|
||||||
|
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
[:next_state, :next_instructions].each do |key|
|
[:next_state, :next_instructions].each do |key|
|
||||||
opts[key] = next_opts[key]
|
opts[key] = next_opts[key]
|
||||||
|
@ -266,6 +266,16 @@ describe DiscourseNarrativeBot::NewUserNarrative do
|
|||||||
expect(new_post.raw).to eq(expected_raw.chomp)
|
expect(new_post.raw).to eq(expected_raw.chomp)
|
||||||
expect(narrative.get_data(user)[:state].to_sym).to eq(:tutorial_onebox)
|
expect(narrative.get_data(user)[:state].to_sym).to eq(:tutorial_onebox)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should skip tutorials in SiteSetting.discourse_narrative_bot_skip_tutorials' do
|
||||||
|
SiteSetting.discourse_narrative_bot_skip_tutorials = 'tutorial_onebox'
|
||||||
|
|
||||||
|
post.update!(raw: "@#{discobot_username} #{skip_trigger.upcase}")
|
||||||
|
|
||||||
|
DiscourseNarrativeBot::TrackSelector.new(:reply, user, post_id: post.id).select
|
||||||
|
|
||||||
|
expect(narrative.get_data(user)[:state].to_sym).to eq(:tutorial_emoji)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'onebox tutorial' do
|
describe 'onebox tutorial' do
|
||||||
|
Reference in New Issue
Block a user