const message = await box.messages.get(id);
message.from; // { address, name, avatar, avatarSource }
message.text;
message.attachments; // [{ id, name, size, mime, inline, contentId, url }]message = box.messages.get(message_id)
message["from"] # {"address", "name", "avatar", "avatarSource"}
message["text"]
message["attachments"] # [{"id", "name", "size", "mime", "inline", "contentId", "url"}]Never render a sender's HTML
Strip it to text, or render it in something that cannot execute. Anyone can send a message, which makes this the most obviously hostile input a product has.
An attachment link lasts fifteen minutes
// A reader left open must renew
setInterval(() => box.messages.get(openId).then(render), 12 * 60_000);import threading
# A reader left open must renew its signed links
def renew():
render(box.messages.get(open_id))
threading.Timer(12 * 60, renew).start()
renew()Past that, images break and downloads are refused while the bytes are perfectly safe. Re-read the message every twelve minutes, and when a tab comes back.
inline alone does not mean « already shown »
Some senders mark every attachment as inline with an identifier, even when the body refers to none of them. A reader that hides on the flag alone hides the photo from the list while the body shows nothing — it disappears twice.
url can be null
The bytes could not be stored — a full quota, or a part that was too large. The attachment is still described, and an honest page says « not available » rather than offering a dead link. A message is never lost for it.
The sender's picture
from.avatar, with avatarSource saying whether it is from your address book or from the sender's domain. Nothing at all when neither exists — keep initials for that.