1
0
mirror of https://github.com/mgerb/classic-wow-forums synced 2026-01-10 17:12:48 +00:00

server/client - rate limiting for threads/replies

This commit is contained in:
2018-01-22 22:03:22 -06:00
parent adbe3c6857
commit 66dd5d5b9a
4 changed files with 44 additions and 10 deletions

View File

@@ -80,6 +80,12 @@ export class Editor extends React.Component<Props, State> {
}
}
getErrorMessage(e: any) {
return get(e, 'response.status') === 429 ?
'You are doing that too much! Please try again in a few minutes.' :
'Server error. Please try again later.';
}
async newReply() {
const { content } = this.state;
@@ -99,7 +105,7 @@ export class Editor extends React.Component<Props, State> {
this.props.editingReply ? await axios.put('/api/reply', data) : await axios.post('/api/reply', data);
this.props.onClose(false);
} catch (e) {
this.setState({ errorMessage: 'Server error. Please try again later.' });
this.setState({ errorMessage: this.getErrorMessage(e) });
}
}
@@ -121,7 +127,7 @@ export class Editor extends React.Component<Props, State> {
await axios.post('/api/thread', data);
this.props.onClose(false);
} catch (e) {
this.setState({ errorMessage: 'Server error. Please try again later.' });
this.setState({ errorMessage: this.getErrorMessage(e) });
}
}