Page: unichat message record
2019-12-02 16:12
Message record
Carries information about teh chat message. It can be short and long. Short version represents deleted messages, where text and some other fieds are not available. Here is the example:
{
"message": {
"id": 34,
"user_id": 367,
"group_id": 54,
"deleted_at": null, // meaning it is not deleted
"serial": 38,
"text": "hello u2!",
"xtag": null,
"attachment": null,
"attachments": [],
"mentions": [], // or null, or array of mention records
"reference": {type: "user", id: "1"},
"forwarded_message_id": 11, // optional: only if not null
"in_reply_to_message_id": 22, // optional: only if not null
"edited_at": null, // was not edited
"created_at": "2018-10-15T18:33:56Z"
"tasks": [<task_record>]
}
}
attachment
field is obsolete, useattachments
.tassk
- array of tasks. For more information, see task_record.
reply and forward
If the message is the forward of another message, it will have forwarded_message_id
field pointing to the original message. Same way in_reply_to_message_id
if
exists, points to the original message to which this one is a reply. To
create forward/reply just add correspodning ids when posting the message.
Message serial
Every time message is changed, say, its text is modified, its serial
field
gets some new value, which is guaranteed to be bigger than it was. This way
the new and changed messages coudl easily be loaded by calling all messages
with serial
bigger than the last (e.g. greatest) known to the client.
This query will automatically add new and changed messages alltogether.
xtag
String tag user with unichat system messages to specify type of special message.
Reference
With some unichat system messages referenced are used to specify some connected object, in which case its type and id are passed in this field.
Files Attachments
If message has attachments, it will be included into message record with
the attachments
key. for example:
"attachments": [
0 => {
"content_type": "image/jpeg",
"byte_size": 1597, // size in bytes
"url": <download_url_string>, // fownload link
"preview": <preview_url_string>, // only for images
"filename":"test.jpg"
}
],
"attachment": {
"content_type": "image/jpeg",
"byte_size": 1597, // size in bytes
"url": <download_url_string>, // fownload link
"preview": <preview_url_string> // only for images
}
- The
attachment
field is obsolete, but left for compatibility with older versions and contains the latest attachment.
The attachment could be of any type, but previews are only available for images.