mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
46 lines
1 KiB
Ruby
46 lines
1 KiB
Ruby
get '/contact' do
|
|
erb :'contact'
|
|
end
|
|
|
|
post '/contact' do
|
|
@errors = []
|
|
|
|
if params[:email].empty? || params[:subject].empty? || params[:body].empty?
|
|
@errors << 'Please fill out all fields'
|
|
end
|
|
|
|
if !recaptcha_valid?
|
|
@errors << 'Captcha was not filled out (or was filled out incorrectly)'
|
|
end
|
|
|
|
if !@errors.empty?
|
|
erb :'contact'
|
|
else
|
|
body = params[:body]
|
|
|
|
if current_site
|
|
body = "current username: #{current_site.username}\n\n" + body
|
|
if parent_site != current_site
|
|
body = "parent username: #{parent_site.username}\n\n" + body
|
|
end
|
|
end
|
|
|
|
if current_site && current_site.supporter?
|
|
subject = "[Neocities Supporter Contact]: #{params[:subject]}"
|
|
else
|
|
subject = "[Neocities Contact]: #{params[:subject]}"
|
|
end
|
|
|
|
EmailWorker.perform_async({
|
|
from: 'web@neocities.org',
|
|
reply_to: params[:email],
|
|
to: 'contact@neocities.org',
|
|
subject: subject,
|
|
body: body,
|
|
no_footer: true
|
|
})
|
|
|
|
flash[:success] = 'Your contact has been sent.'
|
|
redirect '/'
|
|
end
|
|
end
|