Moderation
React to new content that matches a filter.
const stream = live.stream({
model: 'Post',
slug: 'sentiment-moderation',
when: {
created: {
OR: [
{ title: { contains: 'ugly', mode: 'insensitive' } },
{ title: { contains: 'stupid', mode: 'insensitive' } },
],
},
},
})
for await (const event of stream) {
const post = event.created
const sentiment = await analyzeSentiment(post)
if (sentiment === 'rude') {
await suspendUser(post.authorId)
}
}