Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image Moderation: temporarily don't increment abuse score #24626

Merged
merged 3 commits into from Sep 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 8 additions & 9 deletions shared/middleware/files_api.rb
Expand Up @@ -856,15 +856,14 @@ def files_put_file(encrypted_channel_id, filename, body)
project_type = storage_apps.project_type_from_channel_id(encrypted_channel_id)
if MODERATE_THUMBNAILS_FOR_PROJECT_TYPES.include? project_type
file_mime_type = mime_type(File.extname(filename.downcase))
rating = ImageModeration.rate_image(file, file_mime_type, request.fullpath)
if %i(adult racy).include? rating
# Incrementing abuse score by 15 to differentiate from manually reported projects
new_score = storage_apps.increment_abuse(encrypted_channel_id, 15)
FileBucket.new.replace_abuse_score(encrypted_channel_id, s3_prefix, new_score)
response.headers['x-cdo-content-rating'] = rating.to_s
cache_for 1.hour
not_found
end
ImageModeration.rate_image(file, file_mime_type, request.fullpath)
# We are going to re-enable content moderation, but will be adjusting
# the thresholds in a series of trials to optimize for identifying
# inappropriate images without incorrectly flagging appropriate images.
# In the meantime, we don't want to increment abuse score until we
# identify the optimal threshold.
# TODO (ErinB) re-enable abuse score incrementation when
# the correct thresholds are set.
end
end

Expand Down
4 changes: 4 additions & 0 deletions shared/test/middleware/files_api/test_public_thumbnails.rb
Expand Up @@ -10,7 +10,9 @@ def setup
Aws::S3::Client.expects(:new).never
end

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

with_project_type('applab') do |channel_id|
Expand Down Expand Up @@ -38,7 +40,9 @@ def test_adult_thumbnail
end
end

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

with_project_type('applab') do |channel_id|
Expand Down