mirror of
https://github.com/neocities/neocities.git
synced 2025-05-27 22:50:03 +02:00
implement site reporting
This commit is contained in:
parent
5edeba9495
commit
e546b22797
5 changed files with 84 additions and 3 deletions
25
app.rb
25
app.rb
|
@ -963,6 +963,31 @@ post '/comment/:comment_id/delete' do |comment_id|
|
|||
return {result: 'error'}.to_json
|
||||
end
|
||||
|
||||
post '/site/:username/report' do |username|
|
||||
site = Site[username: username]
|
||||
|
||||
redirect request.referer if site.nil?
|
||||
|
||||
report = Report.new site_id: site.id, type: params[:type], comments: params[:comments]
|
||||
|
||||
if current_site
|
||||
report.reporting_site_id = current_site.id
|
||||
else
|
||||
report.ip = request.ip
|
||||
end
|
||||
|
||||
report.save
|
||||
|
||||
EmailWorker.perform_async({
|
||||
from: 'web@neocities.org',
|
||||
to: 'report@neocities.org',
|
||||
subject: "[Neocities Report] #{site.username} has been reported for #{report.type}",
|
||||
body: "Reported by #{report.reporting_site_id ? report.reporting_site.username : report.ip}: #{report.comments}"
|
||||
})
|
||||
|
||||
redirect request.referer
|
||||
end
|
||||
|
||||
def require_admin
|
||||
redirect '/' unless signed_in? && current_site.is_admin
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue