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:
parent
a34bc92e1a
commit
e17d0c0526
|
@ -190,9 +190,13 @@ class TopicCreator
|
|||
add_users(topic, @opts[:target_usernames])
|
||||
add_emails(topic, @opts[:target_emails])
|
||||
add_groups(topic, @opts[:target_group_names])
|
||||
|
||||
if !@added_users.include?(user)
|
||||
topic.topic_allowed_users.build(user_id: @user.id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def save_topic(topic)
|
||||
topic.disable_rate_limits! if @opts[:skip_validations]
|
||||
|
||||
|
@ -228,8 +232,10 @@ class TopicCreator
|
|||
display_name = email.split("@").first
|
||||
|
||||
if user = find_or_create_user(email, display_name)
|
||||
if !@added_users.include?(user)
|
||||
@added_users << user
|
||||
topic.topic_allowed_users.build(user_id: user.id)
|
||||
end
|
||||
len += 1
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue