Fix #4957: Autotag non-web_source.

Autotag non-web_source on posts that have a non-http:// or https:// URL.
Add a fix script to backfill old posts.

Syntactically invalid URLs are still considered web sources. For
example, `https://google,com` technically isn't a valid URL, but it's
not considered a non-web source.
This commit is contained in:
evazion
2022-01-14 22:42:19 -06:00
parent adc5bbf906
commit c3c4f5a2a7
3 changed files with 54 additions and 1 deletions

View File

@@ -404,7 +404,7 @@ class Post < ApplicationRecord
end
def add_automatic_tags(tags)
tags -= %w[incredibly_absurdres absurdres highres lowres flash video ugoira animated_gif animated_png exif_rotation non-repeating_animation]
tags -= %w[incredibly_absurdres absurdres highres lowres flash video ugoira animated_gif animated_png exif_rotation non-repeating_animation non-web_source]
if tags.size >= 30
tags -= ["tagme"]
@@ -443,6 +443,10 @@ class Post < ApplicationRecord
tags << "ugoira"
end
if source.present? && source !~ %r{\Ahttps?://}i
tags << "non-web_source"
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?