posts: automatically add the bad_link and bad_source tags.
Automatically add the bad_link tag when the source is an image url from a known site, but it can't be converted to a page url (for example, a Twitter or Tumblr direct image link). Automatically add the bad_source tag when the source is from a known site, but it's not an image or page url (for example, a Twitter or Pixiv profile url)
This commit is contained in:
@@ -430,6 +430,23 @@ class Post < ApplicationRecord
|
||||
tags << "non-web_source"
|
||||
end
|
||||
|
||||
source_url = parsed_source
|
||||
if source_url.present? && source_url.recognized?
|
||||
# A bad_link is an image URL from a recognized site that can't be converted to a page URL.
|
||||
if source_url.image_url? && source_url.page_url.nil?
|
||||
tags << "bad_link"
|
||||
else
|
||||
tags -= ["bad_link"]
|
||||
end
|
||||
|
||||
# A bad_source is a source from a recognized site that isn't an image url or a page url.
|
||||
if !source_url.image_url? && !source_url.page_url?
|
||||
tags << "bad_source"
|
||||
else
|
||||
tags -= ["bad_source"]
|
||||
end
|
||||
end
|
||||
|
||||
# Allow only Flash files to be manually tagged as `animated`; GIFs, PNGs, videos, and ugoiras are automatically tagged.
|
||||
tags -= ["animated"] unless is_flash?
|
||||
tags << "animated" if media_asset.is_animated?
|
||||
|
||||
Reference in New Issue
Block a user