When the Reply-To header is present for incoming emails we want to use it instead of the from address. This is usually the case when forwarding an email via a mailing list into Discourse.
Do you need to try here?
nil.to_s should be fine
If we make previous change, then you will not need &. as we will end with empty string in worse case
And the same for from_address too. If this line is called, it is only because from_address contains an @, so it is definitely not empty.
Just copied what we already had for
:from underneath Will clean both paths up.
from_display_name = address_field.display_name&.to_s
Adding to the other comments: This line will result in an error if
If this line is executed, it is only because from_address contains an @, so it is definitely not empty.
This is actually not the case; this test is used to catch a from address without an @, so I need to leave the check in