Disallow posting empty message

This commit is contained in:
anthony
2023-09-25 20:25:01 -05:00
parent fc107f1552
commit a6196c38ec
3 changed files with 61 additions and 10 deletions

View File

@@ -763,6 +763,11 @@ module.exports = class Message {
}
persist(cb) {
const containsNonWhitespaceCharacterRegEx = /\S/;
if (!containsNonWhitespaceCharacterRegEx.test(this.message)) {
return cb(Errors.Invalid('Empty message'));
}
if (!this.isValid()) {
return cb(Errors.Invalid('Cannot persist invalid message!'));
}