mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FIX: Bot mentioned check should be case insensitive.
This commit is contained in:
@ -245,13 +245,13 @@ module DiscourseNarrativeBot
|
|||||||
|
|
||||||
def bot_mentioned?
|
def bot_mentioned?
|
||||||
@bot_mentioned ||= PostAnalyzer.new(@post.raw, @post.topic_id).raw_mentions.include?(
|
@bot_mentioned ||= PostAnalyzer.new(@post.raw, @post.topic_id).raw_mentions.include?(
|
||||||
self.discobot_user.username
|
self.discobot_user.username.downcase
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def public_reply?
|
def public_reply?
|
||||||
!SiteSetting.discourse_narrative_bot_disable_public_replies &&
|
!SiteSetting.discourse_narrative_bot_disable_public_replies &&
|
||||||
(bot_mentioned? || reply_to_bot_post?(@post))
|
(reply_to_bot_post?(@post) || bot_mentioned?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def terminate_track(data)
|
def terminate_track(data)
|
||||||
|
@ -427,6 +427,16 @@ describe DiscourseNarrativeBot::TrackSelector do
|
|||||||
expect(new_post.raw).to eq(random_mention_reply)
|
expect(new_post.raw).to eq(random_mention_reply)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should be case insensitive towards discobot's username" do
|
||||||
|
discobot_user.update!(username: 'DisCoBot')
|
||||||
|
|
||||||
|
post.update!(raw: 'Show me what you can do @discobot')
|
||||||
|
described_class.new(:reply, user, post_id: post.id).select
|
||||||
|
new_post = Post.last
|
||||||
|
expect(new_post.raw).to eq(random_mention_reply)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
describe 'rate limiting random reply message in public topic' do
|
describe 'rate limiting random reply message in public topic' do
|
||||||
let(:topic) { Fabricate(:topic) }
|
let(:topic) { Fabricate(:topic) }
|
||||||
let(:other_post) { Fabricate(:post, raw: '@discobot show me something', topic: topic) }
|
let(:other_post) { Fabricate(:post, raw: '@discobot show me something', topic: topic) }
|
||||||
|
Reference in New Issue
Block a user