The Message object
The message object is the very soul of a conversation. It encapsulates all the information need in order to represent a single entry on a message list.
The message object contains these fields:
_id
: The message idrid
: The room id - Identify the room the message belongsmsg
: The textual messagets
: The message time stamp (date of creation on client)u
: The user that sent the message_updatedAt
: The time stamp when the message got saved on the servereditedAt
: (Optional) The time stamp of when the message was editededitedBy
: (Optional) The user that editted the messageurls
: (Optional) A collection of URLs metadata. Available when the message contains at least one URLattachments
: (Optional) A collection of attachment objects, available only when the message has at least one attachmentalias
: (Optional) A way to display the message is “sent” from someone else other than the user who sent the messageavatar
: (Optional) A url to an image, that is accessible to anyone, to display as the avatar instead of the message user’s account avatargroupable
: (Optional) Boolean that states whether or not this message should be grouped together with other messages from the same userparseUrls
: (Optional) Whether Rocket.Chat should try and parse the urls or not
The user presented on u
and editedBy
fields are a simplified version of the user information:
_id
: The user idusername
: The username
The URL metadata contains several informational fields:
url
: The URL itself (just as it appears on the message)meta
: URL metadata (varies accord to the URL)headers
: Some HTTP headers (varies accord to the URL)parsedUrl
: The parsed URL broken into its parts
The attachment object can contain several fields:
image_url
: The image url of the attachmentcolor
: (Optional) The color of the border which displays on the left side of the attachment.
{
"messages": [
{
"_id": "message-id",
"rid": "room-id",
"msg": "Hello World!",
"ts": { "$date": 1480377601 },
"u": {
"_id": "user-id",
"username": "username"
},
"_updatedAt": { "$date": 1480377601 }
},
{
"_id": "message-id",
"rid": "room-id",
"msg": "Hello!",
"ts": { "$date": 1480377601 },
"u": {
"_id": "user-id",
"username": "username"
},
"_updatedAt": { "$date":1480377601 },
"editedAt": { "$date": 1480377601 },
"editedBy": {
"_id": "user-id",
"username": "username"
}
}
]
}