Using Message Metadata
Metadata fields inside messages make it easier to integrate Threads into new and existing projects. Threads are scheme agnostic by design, which makes them easy to integrate into any application. Metadata also allows developers to add any functionalities required by their app.
PrivateMeta
privateMeta
includes additional sensitive information about the message.
It's useful when we need to include the user's private data (personal information, activity details) in the message.
Like the content of the message itself, privateMeta
is encrypted before sending. Since it is saved as binary data, you are free to choose any format.
It can be a JSON parsed to a binary array or a more efficient binary format such as Protocol Buffers.
PublicMeta
Unlike privateMeta
, publicMeta
is not encrypted.
It's useful when you want to include some additional info that does not require encryption.
publicMeta
also does not have a specified structure and supports any binary format.
Example: Response To Another Message
Let's say that you need to implement replies to other messages inside a Thread using publicMeta
.
When sending a message, include the ID of the message you want to reply to. Expanding on the example from the section on sending, it would look like that:
{
"data":{
"content": "string" // string / binary data containing for example: markdown, html or json
},
"info": "ServerInfo", // assigned by server,
"publicMeta":{
"version":"number",
"type": “text”, // some kind of enum describing type of message like “event”, “html”,“markdown” etc.
"responseTo":”{messageID}”
},
}
When displaying the message in a chat, you will be able to find the message that was mentioned and display it according to the application's requirements.