Skip to content

Commit f4b793e

Browse files
authored
Merge pull request code-dot-org#24851 from code-dot-org/revert-24626-dont-use-content-mod-results
Revert "Image Moderation: temporarily don't increment abuse score "
2 parents b8f76e2 + 133fa84 commit f4b793e

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

shared/middleware/files_api.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -857,14 +857,15 @@ def files_put_file(encrypted_channel_id, filename, body)
857857
project_type = storage_apps.project_type_from_channel_id(encrypted_channel_id)
858858
if MODERATE_THUMBNAILS_FOR_PROJECT_TYPES.include? project_type
859859
file_mime_type = mime_type(File.extname(filename.downcase))
860-
ImageModeration.rate_image(file, file_mime_type, request.fullpath)
861-
# We are going to re-enable content moderation, but will be adjusting
862-
# the thresholds in a series of trials to optimize for identifying
863-
# inappropriate images without incorrectly flagging appropriate images.
864-
# In the meantime, we don't want to increment abuse score until we
865-
# identify the optimal threshold.
866-
# TODO (ErinB) re-enable abuse score incrementation when
867-
# the correct thresholds are set.
860+
rating = ImageModeration.rate_image(file, file_mime_type, request.fullpath)
861+
if %i(adult racy).include? rating
862+
# Incrementing abuse score by 15 to differentiate from manually reported projects
863+
new_score = storage_apps.increment_abuse(encrypted_channel_id, 15)
864+
FileBucket.new.replace_abuse_score(encrypted_channel_id, s3_prefix, new_score)
865+
response.headers['x-cdo-content-rating'] = rating.to_s
866+
cache_for 1.hour
867+
not_found
868+
end
868869
end
869870
end
870871

shared/test/middleware/files_api/test_public_thumbnails.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ def setup
1010
Aws::S3::Client.expects(:new).never
1111
end
1212

13-
#Disabled while we gather Azure moderation stats. (PR 24626)'
1413
def test_adult_thumbnail
15-
skip
1614
ImageModeration.stubs(:rate_image).once.returns :adult
1715

1816
with_project_type('applab') do |channel_id|
@@ -40,9 +38,7 @@ def test_adult_thumbnail
4038
end
4139
end
4240

43-
#Disabled while we gather Azure moderation stats. (PR 24626)'
4441
def test_racy_thumbnail
45-
skip
4642
ImageModeration.stubs(:rate_image).once.returns :racy
4743

4844
with_project_type('applab') do |channel_id|

0 commit comments

Comments
 (0)