mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 09:03:39 +08:00
FIX: Discobot exception when site_contact_username is promoted (#11666)
Because the site admin is sending a message to themselves, there is only one user in the topic_allowed_users, and `.last` returns nil. Attempt to recognize this situation and continue, or bail without doing anything if this somehow happens another way.
This commit is contained in:
@ -302,7 +302,9 @@ after_initialize do
|
||||
discobot_username: ::DiscourseNarrativeBot::Base.new.discobot_username,
|
||||
reset_trigger: "#{::DiscourseNarrativeBot::TrackSelector.reset_trigger} #{::DiscourseNarrativeBot::AdvancedUserNarrative.reset_trigger}")
|
||||
|
||||
recipient = args[:post].topic.topic_users.where.not(user_id: args[:post].user_id).last.user
|
||||
recipient = args[:post].topic.topic_users.where.not(user_id: args[:post].user_id).last&.user
|
||||
recipient ||= Discourse.site_contact_user if args[:post].user == Discourse.site_contact_user
|
||||
return if recipient.nil?
|
||||
|
||||
PostCreator.create!(
|
||||
::DiscourseNarrativeBot::Base.new.discobot_user,
|
||||
|
Reference in New Issue
Block a user