diff --git a/models/site.rb b/models/site.rb
index c93d258b..e0afcb1f 100644
--- a/models/site.rb
+++ b/models/site.rb
@@ -70,6 +70,8 @@ class Site < Sequel::Model
/PHP\.Hide/
]
+ SPAM_MATCH_REGEX = /#{$config['spam_smart_filter'].join('|')}/i
+
EMAIL_SANITY_REGEX = /.+@.+\..+/i
EDITABLE_FILE_EXT = /html|htm|txt|js|css|md/i
@@ -342,6 +344,24 @@ class Site < Sequel::Model
return false
end
+ open(uploaded.path) { |f| matches = f.grep SPAM_MATCH_REGEX }
+
+ if !matches.empty?
+ EmailWorker.perform_async({
+ from: 'web@neocities.org',
+ reply_to: email,
+ to: 'spam@neocities.org',
+ subject: "[Neocities SPAM]: #{username}",
+ body: %{
+ #{username}
+
+ https://#{self.host}#{relative_path}
+
+ link
+ }
+ })
+ end
+
pathname = Pathname(path)
if pathname.basename.to_s == 'index.html'
new_title = Nokogiri::HTML(File.read(uploaded.path)).css('title').first.text