-
Notifications
You must be signed in to change notification settings - Fork 25
Get message bodies along with metadata #50
Description
As discussed in the mailing list (https://groups.google.com/forum/#!topic/elasticinbox/LW6DGE157HA) it might be necessary to provide a method to retrieve message bodies along with their metadata when requesting a message listing.
Rationale: We've discovered a common use case when developing a client for ElasticInbox where we need to show a small excerpt of each message listed on the mailbox. In such instance currently are needed 1 + n requests, where n is the number of messages displayed per page. The first request is for retrieving the list, the remaining n requests are for retrieving each and every message body. This is inefficient. If ElasticInbox could be configured to return the bodies along with the metadata the requests could be cut to just 1.
Proposal:
- Add a
includebodies=trueparameter to the listing url. includebodieswill not have effect ifmetadata=trueis not present.- It could be beneficial to configure ElasticInbox to truncate the bodies to a specified length. Note that this could result in invalid HTML output due to missing closing tags.
Example request:
http://mail.example.com/rest/v2/example.com/danita/mailbox/label/1?metadata=true&includebodies=true
Example response:
{
944e8900-6382-11e3-852b-22000a9887a0: {
from: [
{ name: "Example.com", address: "[email protected]" }
],
to: [
{ name: "Danita", address: "[email protected]" },
],
cc: null,
bcc: null,
subject: "Newsletter #661",
date: "2013-12-12T18:46:15.000+0000",
messageId: null,
size: 22336,
location: "blob://db/944e8900-6382-11e3-852b-22000a9887a0?c=dfl&b=1",
plainBody: "Newsletter #661: Principles of interaction design...",
htmlBody: "<html><head></head><body><h1>Newsletter #661: Principles of interaction design</h1><p>...</p></body></html>",
labels: [ 0, 1, 10 ],
markers: [ "SEEN" ],
parts: null
},
...
}