mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:29:30 +08: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")
|
.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'")
|
.joins("LEFT OUTER JOIN reviewables r ON r.target_id = users.id AND r.target_type = 'User'")
|
||||||
.where('r.id IS NULL')
|
.where('r.id IS NULL')
|
||||||
.joins('LEFT OUTER JOIN user_custom_fields ucf ON users.id = ucf.user_id')
|
.joins(
|
||||||
.group('users.id, ucf.id')
|
<<~SQL
|
||||||
.having('ucf.id IS NULL OR NOT bool_or(ucf.name = ?)', 'import_id')
|
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)
|
.limit(10)
|
||||||
|
|
||||||
users.each do |user|
|
users.each do |user|
|
||||||
|
|
|
@ -80,5 +80,13 @@ describe Jobs::EnqueueSuspectUsers do
|
||||||
|
|
||||||
expect(ReviewableUser.where(target: suspect_user).exists?).to eq(true)
|
expect(ReviewableUser.where(target: suspect_user).exists?).to eq(true)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user