This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add
check_media_file_for_spam
spam checker hook #9311Add
check_media_file_for_spam
spam checker hook #9311Changes from all commits
7e8083e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we include some info about what was blocked while logging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't actually know very much about the media annoyingly, e.g. we don't know the media ID. I hope we can extract enough info from the request logs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't
file_info
have some stuff in it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it has some stuff, but not the media ID. We could log if its a remote download or not, but I'm not sure that is particularly useful given you can get that from the request logs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see all that info is pretty much in the requests logs. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rationale here is that we don't want to give the raw path to the spam checker so that people don't just do
file.read()
, potentially blocking the reactor while we do large reads. Instead we do whatFileSender
does and read small chunks, yielding to the reactor between reads. I'm not 100% if that's the right way of doing things, but at least it's what we currently do for file downloads.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's really not the right way of doing things. Irrespective of whether non-blocking IO is perfect, it's better than doing regular IO on the reactor thread.
This is probably good enough for a quick hack, but it would be nice to come back to it and either make a non-blocking-io thing which integrates with the twisted reactor, or give up and uses threads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have filed #9312. Doing it like this is at least not making anything worse