Truncate implies removing all messages from the channel. This will not delete the channel instead wipe out the messages from the channel.
This can be done from the client-side/server-side. I am using an admin user.
Steps in detail
Create and initialize the channel
const channelID="live1"
const conversationlive = client.channel("livestream",channelID, {
name: 'fourthlive',
members: ['Seetha', 'Stephen'],
});
await conversationlive.create();
Send Message
const livemessage = await conversationlive.sendMessage({
text: 'Fourth livestream Helloo',
attachments: [
{
type: 'image',
asset_url: 'https://bit.ly/2K74TaG',
thumb_url: 'https://bit.ly/2Uumxti',
myCustomField: 1
}
],
mentioned_users: ['Seetha'],
anotherCustomField: 1
});
Query Channel
const channel = client.channel("livestream", 'fourthlive' , {});
const lastMessageID = '';
const result = await channel.query({
messages: { limit: 20, id_lt: lastMessageID},
members: { limit: 20, offset: 0 },
watchers: { limit: 20, offset: 0 }
});
console.log(result);
}
Response -
messages: [
{
id: '008b1458-f230-425a-82cf-be5eecffe84d',
text: 'Fourth livestream Helloo',
html: '<p>Fourth livestream Helloo</p>\n',
type: 'regular',
user: [Object],
attachments: [Array],
latest_reactions: [],
own_reactions: [],
reaction_counts: {},
reaction_scores: null,
reply_count: 0,
created_at: '2020-09-29T06:03:14.451023Z',
updated_at: '2020-09-29T06:03:14.451024Z',
mentioned_users: [Array],
silent: false,
anotherCustomField: 1
},
]
Truncate
const trunc = await conversationlive.truncate();
console.log(trunc);
Response -
messages: [],
Comments
0 comments
Please sign in to leave a comment.