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/b58cae926b410b6cc1950314ac656c00 to your computer and use it in GitHub Desktop.
Save anchetaWern/b58cae926b410b6cc1950314ac656c00 to your computer and use it in GitHub Desktop.
React Native Stream Chat Profanity Filtering: Temporarily comment out add member and beyond
async componentDidMount() {
this.props.navigation.setParams({
showUsersModal: this.showUsersModal
});
try {
const user = await client.setUser(
{
id: this.user_id,
name: this.username,
image: `https://ui-avatars.com/api/?background=d88413&color=FFF&name=${this.username}`,
},
this.user_token
);
console.log("user is set!", user);
/*
await axios.post(`${CHAT_SERVER}/add-member`, {
user_id: this.user_id
});
const channel = client.channel('messaging', 'sample-room1');
this.channel = channel;
const channel_state = await channel.watch({ presence: true });
this.channel_state = channel_state;
this.setState({
is_ready: true
});
await this.asyncForEach(channel_state.messages, async (msg) => {
const { message } = this.getMessage(msg);
await this.setState((previousState) => ({
messages: GiftedChat.append(previousState.messages, message)
}));
});
channel.on('message.new', async (event) => {
const { message } = this.getMessage(event.message);
await this.setState((previousState) => ({
messages: GiftedChat.append(previousState.messages, message)
}));
});
channel.on('message.updated', async (event) => {
const { message } = this.getMessage(event.message);
if (message.user._id == this.user_id) {
if (message.user.warn_count < 3) {
Alert.alert("Profanity warning", "You will be banned indefinitely on the 3rd time you do this.");
} else {
Alert.alert("Banned indefinitely", "You have now been banned from using this service");
}
}
this.setState(state => {
const messages = state.messages.map((item) => {
if (item._id == message._id) {
return { ...item, text: message.text };
} else {
return item;
}
});
return {
messages
}
});
});
*/
} catch (err) {
console.log("error: ", err);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment