mysociety / alaveteli

Provide a Freedom of Information request system for your jurisdiction
https://alaveteli.org
Other
389 stars 195 forks source link

Email address shown in `/admin/outgoing_messages` is not always correct #7425

Open mdeuk opened 1 year ago

mdeuk commented 1 year ago

When #7390 was implemented, the To, From, and Subject fields from outgoing messages became visible in the respective admin page. This is very useful, but, there does appear to be a slight issue.

Looking at outgoing message 1365974 on WDTK, the email address rendered there is the current email address for the body, but not the one that we sent the message to.

Expected behaviour

The From email address shown should match the one shown in the Params yaml of the respective event (13205224), e.g. contactcentre@

Actual behaviour

The From email address shown is the one configured in Alaveteli as the mailbox to send new requests to (dataprotection@).

This will be correct in many cases, but it doesn't take into account an instance such as this - where the email address for the public body has changed in the period between the message being sent and the change being made.

garethrees commented 1 year ago

Yeah, this is a bit of a gotcha in that the To address is currently dynamically calculated, not cached at the time of sending. It hasn't really been a problem since we didn't render it so obviously, but indeed, now that we do present it it's a bit confusing in the cases that it's wrong. Had a similar issue in diagnosing https://github.com/mysociety/asktheeu-theme/pull/122 with some of the IncomingMessage address fields.

garethrees commented 1 year ago

I think to fix we need to:

  1. Cache the address at the time of sending.
  2. Update the resend mechanism to use the latest body address if we're not replying to a more specific From address from one of the responses.