Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anchetaWern/288f78d03877cfb0315deefc51c02fa0 to your computer and use it in GitHub Desktop.
Save anchetaWern/288f78d03877cfb0315deefc51c02fa0 to your computer and use it in GitHub Desktop.
React Native Stream Chat Profanity Filtering: Check for error when sending message
onSend = async ([message]) => {
const message_response = await this.channel.sendMessage({
text: message.text
});
if (message_response.message.type == 'error') {
Alert.alert("Error", message_response.message.text);
}
}
/*
// sample message_response:
{
"message":{
"id":"xxxxfe5a-xxxx-4a20-xxxx-73xxxxxx009",
"text":"hello",
"html":"<p>hello</p>\n",
"type":"regular",
"user":{
"id":"1xxxxxxx",
"role":"user",
"created_at":"2019-06-26T01:25:55.854662Z",
"updated_at":"2019-06-26T05:25:25.985744Z",
"last_active":"2019-06-26T05:28:26.176400162Z",
"online":true,
"warn_count":3,
"name":"norman",
"image":"https://ui-avatars.com/api/?background=d88413&color=FFF&name=norman"
},
"attachments":[
],
"latest_reactions":[
],
"own_reactions":[
],
"reaction_counts":null,
"reply_count":0,
"created_at":"2019-06-26T05:28:32.789462Z",
"updated_at":"2019-06-26T05:28:32.789462Z",
"mentioned_users":[
]
},
"duration":"9.75ms"
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment