-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
112 changed files
with
1,332 additions
and
387 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
$default-space: 15px; | ||
$contact-padding: $default-space * 2; | ||
|
||
#contact-form { | ||
width: 1040px; | ||
margin: 0 auto; | ||
padding-top: $contact-padding; | ||
|
||
.description { | ||
padding-bottom: $contact-padding; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
class NewUser::FeedbacksController < ApplicationController | ||
def create | ||
current_user.feedbacks.create!(rating: params[:rating]) | ||
flash.notice = "Merci de votre retour, si vous souhaitez nous en dire plus, n'hésitez pas à <a href='mailto:#{CONTACT_EMAIL}' target='_blank'>nous contacter par email</a>." | ||
flash.notice = "Merci de votre retour, si vous souhaitez nous en dire plus, n'hésitez pas à #{view_context.contact_link('nous contacter', type: Helpscout::FormAdapter::TYPE_AMELIORATION)}." | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
class SupportController < ApplicationController | ||
layout "new_application" | ||
|
||
def index | ||
setup_context | ||
end | ||
|
||
def create | ||
if direct_message? && create_commentaire | ||
flash.notice = "Votre message a été envoyé sur la messagerie de votre dossier." | ||
|
||
redirect_to users_dossier_recapitulatif_path(dossier) | ||
elsif create_conversation | ||
flash.notice = "Votre message a été envoyé." | ||
|
||
redirect_to root_path | ||
else | ||
setup_context | ||
flash.now.alert = "Une erreur est survenue. Vous pouvez nous contactez à #{CONTACT_EMAIL}." | ||
|
||
render :index | ||
end | ||
end | ||
|
||
private | ||
|
||
def setup_context | ||
@dossier_id = dossier&.id | ||
@type = params[:type] | ||
@tags = params[:tags] | ||
@options = Helpscout::FormAdapter::OPTIONS | ||
end | ||
|
||
def create_conversation | ||
Helpscout::FormAdapter.new( | ||
subject: params[:subject], | ||
email: email, | ||
text: params[:text], | ||
file: params[:file], | ||
dossier_id: dossier&.id, | ||
browser: browser_name, | ||
tags: tags | ||
).send_form | ||
end | ||
|
||
def create_commentaire | ||
dossier.commentaires.create( | ||
email: email, | ||
file: params[:file], | ||
body: "[#{params[:subject]}]<br><br>#{params[:text]}" | ||
) | ||
end | ||
|
||
def tags | ||
[params[:tags], params[:type]].flatten.compact | ||
end | ||
|
||
def browser_name | ||
if browser.known? | ||
"#{browser.name} #{browser.version} (#{browser.platform.name})" | ||
end | ||
end | ||
|
||
def direct_message? | ||
user_signed_in? && params[:type] == Helpscout::FormAdapter::TYPE_INSTRUCTION && dossier.present? | ||
end | ||
|
||
def dossier | ||
@dossier ||= current_user&.dossiers&.find_by(id: params[:dossier_id]) | ||
end | ||
|
||
def email | ||
logged_user ? logged_user.email : params[:email] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
class WebhookController < ActionController::Base | ||
before_action :verify_signature!, only: :helpscout | ||
|
||
def helpscout | ||
email = params[:customer][:email] | ||
user = User.find_by(email: email) | ||
gestionnaire = Gestionnaire.find_by(email: email) | ||
administrateur = Administrateur.find_by(email: email) | ||
html = [] | ||
|
||
if user | ||
url = view_context.manager_user_url(user) | ||
html << link_to_manager(user, url) | ||
end | ||
|
||
if gestionnaire | ||
url = view_context.manager_gestionnaire_url(gestionnaire) | ||
html << link_to_manager(gestionnaire, url) | ||
end | ||
|
||
if administrateur | ||
url = view_context.manager_administrateur_url(administrateur) | ||
html << link_to_manager(administrateur, url) | ||
end | ||
|
||
if html.empty? | ||
head :not_found | ||
else | ||
render json: { html: html.join('<br>') } | ||
end | ||
end | ||
|
||
private | ||
|
||
def link_to_manager(model, url) | ||
"<a target='_blank' href='#{url}'>#{model.model_name.human}##{model.id}</a>" | ||
end | ||
|
||
def verify_signature! | ||
if generate_body_signature(request.body.read) != request.headers['X-Helpscout-Signature'] | ||
request_http_token_authentication | ||
end | ||
end | ||
|
||
def generate_body_signature(body) | ||
Base64.strict_encode64(OpenSSL::HMAC.digest('sha1', | ||
Rails.application.secrets.helpscout[:webhook_secret], | ||
body)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.