mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FIX: don't double add users to topic allowed users
In latest rails building the same relation twice results in an error Previous versions would deduplicate
This commit is contained in:
@ -190,7 +190,11 @@ class TopicCreator
|
|||||||
add_users(topic, @opts[:target_usernames])
|
add_users(topic, @opts[:target_usernames])
|
||||||
add_emails(topic, @opts[:target_emails])
|
add_emails(topic, @opts[:target_emails])
|
||||||
add_groups(topic, @opts[:target_group_names])
|
add_groups(topic, @opts[:target_group_names])
|
||||||
topic.topic_allowed_users.build(user_id: @user.id)
|
|
||||||
|
if !@added_users.include?(user)
|
||||||
|
topic.topic_allowed_users.build(user_id: @user.id)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_topic(topic)
|
def save_topic(topic)
|
||||||
@ -228,8 +232,10 @@ class TopicCreator
|
|||||||
display_name = email.split("@").first
|
display_name = email.split("@").first
|
||||||
|
|
||||||
if user = find_or_create_user(email, display_name)
|
if user = find_or_create_user(email, display_name)
|
||||||
@added_users << user
|
if !@added_users.include?(user)
|
||||||
topic.topic_allowed_users.build(user_id: user.id)
|
@added_users << user
|
||||||
|
topic.topic_allowed_users.build(user_id: user.id)
|
||||||
|
end
|
||||||
len += 1
|
len += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user