mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
FIX: Don't enqueue imported users when there're multiple custom fields. (#11559)
My initial implementation didn't consider this case. We should skip imported users if the "imported_id" field is present, even if there're other custom fields.
This commit is contained in:
parent
a4fb28ccd8
commit
8a7fe3b276
@ -19,9 +19,16 @@ module Jobs
|
||||
.where("user_stats.posts_read_count <= 1 AND user_stats.topics_entered <= 1")
|
||||
.joins("LEFT OUTER JOIN reviewables r ON r.target_id = users.id AND r.target_type = 'User'")
|
||||
.where('r.id IS NULL')
|
||||
.joins('LEFT OUTER JOIN user_custom_fields ucf ON users.id = ucf.user_id')
|
||||
.group('users.id, ucf.id')
|
||||
.having('ucf.id IS NULL OR NOT bool_or(ucf.name = ?)', 'import_id')
|
||||
.joins(
|
||||
<<~SQL
|
||||
LEFT OUTER JOIN (
|
||||
SELECT user_id
|
||||
FROM user_custom_fields
|
||||
WHERE user_custom_fields.name = 'import_id'
|
||||
) AS ucf ON ucf.user_id = users.id
|
||||
SQL
|
||||
)
|
||||
.where('ucf.user_id IS NULL')
|
||||
.limit(10)
|
||||
|
||||
users.each do |user|
|
||||
|
@ -80,5 +80,13 @@ describe Jobs::EnqueueSuspectUsers do
|
||||
|
||||
expect(ReviewableUser.where(target: suspect_user).exists?).to eq(true)
|
||||
end
|
||||
|
||||
it 'ignores imported users even if they have multiple custom fields' do
|
||||
suspect_user.upsert_custom_fields({ field_a: 'value', field_b: 'value', import_id: 'fake_id' })
|
||||
|
||||
subject.execute({})
|
||||
|
||||
expect(ReviewableUser.where(target: suspect_user).exists?).to eq(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user