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

@@ -0,0 +1,25 @@
#!/usr/bin/env ruby
require_relative "base"
CurrentUser.scoped(User.system) do
Post.system_tag_match("-source:none -source:http://* -source:https://* -non-web_source").find_each do |post|
puts "post ##{post.id}: adding non-web_source"
post.save!
end
Post.system_tag_match("source:none non-web_source").find_each do |post|
puts "post ##{post.id}: removing non-web_source"
post.save!
end
Post.system_tag_match("source:http://* non-web_source").find_each do |post|
puts "post ##{post.id}: removing non-web_source"
post.save!
end
Post.system_tag_match("source:https://* non-web_source").find_each do |post|
puts "post ##{post.id}: removing non-web_source"
post.save!
end
end