mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-11 18:47:51 +08:00
[local-sync] Remove unused message update hook
Summary: Message bodies, drafts aside, are immutable, and we set the snippet on new messages manually in parseFromImap()---meaning this hook, if invoked, is likely to replace the snippet with a broken version computed with this old implementation. If we need a hook in the future (e.g. for updating drafts), it should use the snippet function from message-factory. Test Plan: n/a Reviewers: juan, halla Reviewed By: juan Differential Revision: https://phab.nylas.com/D3622
This commit is contained in:
parent
1e6f7a6e6f
commit
fb705fc5dd
2 changed files with 5 additions and 14 deletions
|
@ -23,7 +23,6 @@
|
|||
"rx": "4.1.0",
|
||||
"sequelize": "nylas/sequelize#nylas-3.30.0",
|
||||
"sqlite3": "https://github.com/bengotow/node-sqlite3/archive/bengotow/usleep-v3.1.4.tar.gz",
|
||||
"striptags": "2.1.1",
|
||||
"underscore": "1.8.3",
|
||||
"vision": "4.1.0"
|
||||
},
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
const crypto = require('crypto')
|
||||
const striptags = require('striptags');
|
||||
const {PromiseUtils, IMAPConnection} = require('isomorphic-core')
|
||||
const {DatabaseTypes: {JSONArrayColumn}} = require('isomorphic-core');
|
||||
const {Errors: {APIError}} = require('isomorphic-core')
|
||||
|
||||
|
||||
const SNIPPET_LENGTH = 191;
|
||||
|
||||
function validateRecipientsPresent(message) {
|
||||
if (message.getRecipients().length === 0) {
|
||||
throw new APIError(`No recipients specified`, 400);
|
||||
|
@ -25,6 +22,11 @@ module.exports = (sequelize, Sequelize) => {
|
|||
subject: Sequelize.STRING(500),
|
||||
snippet: Sequelize.STRING(255),
|
||||
date: Sequelize.DATE,
|
||||
// TODO: We do not currently sync drafts with the remote. When we add
|
||||
// this feature, we need to be careful because this breaks the assumption
|
||||
// that messages, modulo their flags and folders/labels, are immutable.
|
||||
// Particularly, we will need to implement logic to make sure snippets
|
||||
// stay in sync with the current message body.
|
||||
isDraft: Sequelize.BOOLEAN,
|
||||
isSent: Sequelize.BOOLEAN,
|
||||
isSending: Sequelize.BOOLEAN,
|
||||
|
@ -67,16 +69,6 @@ module.exports = (sequelize, Sequelize) => {
|
|||
{fields: ['gMsgId']}, // Use in `searchThreads`
|
||||
{fields: ['folderImapUID']}, // Use in `searchThreads`
|
||||
],
|
||||
hooks: {
|
||||
beforeUpdate(message) {
|
||||
// Update the snippet if the body has changed
|
||||
if (!message.changed('body')) { return; }
|
||||
|
||||
const plainText = striptags(message.body);
|
||||
// consolidate whitespace groups into single spaces and then truncate
|
||||
message.snippet = plainText.split(/\s+/).join(" ").substring(0, SNIPPET_LENGTH)
|
||||
},
|
||||
},
|
||||
classMethods: {
|
||||
associate({Message, Folder, Label, File, Thread, MessageLabel}) {
|
||||
Message.belongsTo(Thread)
|
||||
|
|
Loading…
Reference in a new issue