Prevent >64k text in composition box; truncate too-large drafts
This commit is contained in:
parent
87ae65c852
commit
095cd884a2
5 changed files with 116 additions and 7 deletions
|
@ -8,6 +8,8 @@
|
|||
|
||||
window.Whisper = window.Whisper || {};
|
||||
|
||||
const MAX_MESSAGE_BODY_LENGTH = 64 * 1024;
|
||||
|
||||
const conversations = new Whisper.ConversationCollection();
|
||||
const inboxCollection = new (Backbone.Collection.extend({
|
||||
initialize() {
|
||||
|
@ -183,12 +185,25 @@
|
|||
|
||||
this._initialFetchComplete = true;
|
||||
await Promise.all(
|
||||
conversations.map(conversation => {
|
||||
conversations.map(async conversation => {
|
||||
if (!conversation.get('lastMessage')) {
|
||||
return conversation.updateLastMessage();
|
||||
await conversation.updateLastMessage();
|
||||
}
|
||||
|
||||
return null;
|
||||
// In case a too-large draft was saved to the database
|
||||
const draft = conversation.get('draft');
|
||||
if (draft && draft.length > MAX_MESSAGE_BODY_LENGTH) {
|
||||
this.model.set({
|
||||
draft: draft.slice(0, MAX_MESSAGE_BODY_LENGTH),
|
||||
});
|
||||
await window.Signal.Data.updateConversation(
|
||||
conversation.id,
|
||||
conversation.attributes,
|
||||
{
|
||||
Conversation: Whisper.Conversation,
|
||||
}
|
||||
);
|
||||
}
|
||||
})
|
||||
);
|
||||
window.log.info('ConversationController: done with initial fetch');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue