Files
netig.net/routes/contact.rb
T
2026-10-22 01:07:27 +02:00

38 lines
1.1 KiB
Ruby

class Netig
hash_branch "contact" do |r|
r.is do
r.get do
@page_title = "Contact — NETig"
@page_description = "Contacter NETig pour toute question concernant ses services."
@canonical_url = "https://netig.net/contact"
view "contact"
end
end
r.post "send" do
check_csrf!
form = ContactForm.new(r.params)
if form.spam?
flash["notice"] = "Votre message a été reçu."
r.redirect "/contact"
elsif form.valid?
begin
ContactMailer.new(r.params).deliver
flash["notice"] = "Votre message a été envoyé."
rescue Net::SMTPError, SocketError, SystemCallError, IOError, Timeout::Error, OpenSSL::SSL::SSLError => error
warn "Échec SMTP : #{error.class}"
flash["error"] = "L'envoi a échoué. Veuillez réessayer plus tard."
end
r.redirect "/contact"
else
response.status = 422
flash.now["error"] = "Veuillez vérifier les champs du formulaire."
view "contact"
end
end
end
end