betagouv / betaGouvBot

Automated assistant for beta.gouv.fr administrative tasks on slack.
https://beta.gouv.fr
MIT License
4 stars 10 forks source link

Switch emails to Markdown #9

Closed MattiSG closed 7 years ago

MattiSG commented 7 years ago

The emails I receive are in HTML, and the text source is definitely interpreted as Markdown.

capture d ecran 2017-02-22 a 14 30 53

I don't know how to test this though.

Morendil commented 7 years ago

What specifically are you seeing that suggests to you that something is being interpreted as Markdown ? Where is that Markdown processor running ?

MattiSG commented 7 years ago

What specifically are you seeing that suggests to you that something is being interpreted as Markdown?

  1. URLs are rendered in monospace as code, due to indentation.
  2. Newlines are inserted between those code blocks and the text.
  3. The asterisk is rendered as a bullet list.

Plus, I get an HTML part when I look at the raw email…

Where is that Markdown processor running?

This, my friend, I don't pretend to know… On the service provider (Sendgrid)'s end, I guess?

Morendil commented 7 years ago

Thanks, that narrows down the hypothesis to test considerably. My plan is to run a test by manually sending some markdown via Sendgrid.

Morendil commented 7 years ago

I sent myself an email using the following procedure:

> heroku run irb
irb> lib = File.expand_path('../lib', __FILE__)
irb> $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
irb> require 'betagouvbot'
irb> mailer = BetaGouvBot::Mailer
irb> envelope = (a json string)
irb> body = "[this is a link](http://localhost)"
irb> email = mailer.format_email(body,envelope,{})
irb> mailer.client.post(request_body: email)

In the email I received, the link code was not interpreted.

So SendGrid is in fact post-processing the text of emails sent via Mailer (in particular by adding tracking wrappers to link targets, which bothers me quite a bit), but this processor is not a Markdown parser.