I think this should use the same logic than https://github.com/mozilla-b2g/gaia/blob/master/apps/sms/js/thread_ui.js#L1122-L1143

if blob => create attachment, append it (I think it already checks if name is not undefined)
if text => append it

here you have multiple nested if blocks, this is not readable, and I don't like having 2 different algorithms in 2 different parts.

We don't need to factorize the code in ThreadUI and here (yet), but at least try to use the same algorithm.