getMessages
Returns an array of encrypted messages from a conversation.
How to use?
Messages can be decrypted using decryptMessage
.
const { data, error } = await orbis.getMessages(conversation_id);
Parameters
conversation_id
- (stream) ID of the conversation you're querying messages from
Returns
[
{
stream_id: "k...",
conversation_id: "k...",
creator: "did:pkh:...",
content: {
conversation_id: "k...",
encryptedMessage: {
encryptedString: "...",
encryptedSymmetricKey: "...",
accessControlConditions: "[]"
}
},
creator_details: {
did: "did:pkh:...",
profile: {
username: "Baptiste",
pfp: "https://..."
}
},
},
...
]
Examples
Retrieve and decrypt messages from a conversation
/** Retrieve an array messages from a conversation */
const { data: messages } = await orbis.getMessages("k...");
/** Loop through the message array and log decrypted contents */
for(const message of messages){
const decryptedMessage = await orbis.decryptMessage(message.content)
console.log(decryptedMessage.result)
}