Don't send if message body is too long
This commit is contained in:
parent
6cf4f19317
commit
b31fbcaa17
|
@ -1378,6 +1378,10 @@
|
|||
"description":
|
||||
"Timestamp format string for displaying month and day (but not the year) of a date within the current year, ex: use 'MMM D' for 'Aug 8', or 'D MMM' for '8 Aug'."
|
||||
},
|
||||
"messageBodyTooLong": {
|
||||
"message": "Message body is too long.",
|
||||
"description": "Shown if the user tries to send more than 64kb of text"
|
||||
},
|
||||
"unblockToSend": {
|
||||
"message": "Unblock this contact to send a message.",
|
||||
"description": "Brief message shown when trying to message a blocked number"
|
||||
|
|
|
@ -64,6 +64,13 @@
|
|||
},
|
||||
});
|
||||
|
||||
const MAX_MESSAGE_BODY_LENGTH = 64 * 1024;
|
||||
Whisper.MessageBodyTooLongToast = Whisper.ToastView.extend({
|
||||
render_attributes() {
|
||||
return { toastMessage: i18n('messageBodyTooLong') };
|
||||
},
|
||||
});
|
||||
|
||||
Whisper.ConversationLoadingScreen = Whisper.View.extend({
|
||||
templateName: 'conversation-loading-screen',
|
||||
className: 'conversation-loading-screen',
|
||||
|
@ -1653,6 +1660,9 @@
|
|||
this.closeEmojiPanel();
|
||||
this.model.clearTypingTimers();
|
||||
|
||||
const input = this.$messageField;
|
||||
const message = window.Signal.Emoji.replaceColons(input.val()).trim();
|
||||
|
||||
let toast;
|
||||
if (extension.expired()) {
|
||||
toast = new Whisper.ExpiredToast();
|
||||
|
@ -1666,6 +1676,9 @@
|
|||
if (!this.model.isPrivate() && this.model.get('left')) {
|
||||
toast = new Whisper.LeftGroupToast();
|
||||
}
|
||||
if (message.length > MAX_MESSAGE_BODY_LENGTH) {
|
||||
toast = new Whisper.MessageBodyTooLongToast();
|
||||
}
|
||||
|
||||
if (toast) {
|
||||
toast.$el.appendTo(this.$el);
|
||||
|
@ -1674,9 +1687,6 @@
|
|||
return;
|
||||
}
|
||||
|
||||
const input = this.$messageField;
|
||||
const message = window.Signal.Emoji.replaceColons(input.val()).trim();
|
||||
|
||||
try {
|
||||
if (!message.length && !this.fileInput.hasFiles()) {
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue