mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-21 07:46:06 +08:00
[local-sync] Set thread IDs to the ID of a message in the thread
Since message IDs are now static but there's no good way to generate static thread IDs while syncing an account from newest message first, we give threads the ID of any message on that thread and, when setting metadata, look up the local thread ID by first going through the message table.
This commit is contained in:
parent
d9f3edad0f
commit
9752eea9f7
|
@ -2,6 +2,7 @@ const {DatabaseTypes: {JSONARRAYType}} = require('isomorphic-core');
|
|||
|
||||
module.exports = (sequelize, Sequelize) => {
|
||||
return sequelize.define('thread', {
|
||||
id: { type: Sequelize.STRING(65), primaryKey: true },
|
||||
accountId: { type: Sequelize.STRING, allowNull: false },
|
||||
version: Sequelize.INTEGER,
|
||||
remoteThreadId: Sequelize.STRING,
|
||||
|
|
|
@ -95,6 +95,11 @@ function detectThread({db, message}) {
|
|||
|
||||
// update the basic properties of the thread
|
||||
thread.accountId = message.accountId;
|
||||
// Threads may, locally, have the ID of any message within the thread
|
||||
// (message IDs are globally unique, even across accounts!)
|
||||
if (!thread.id) {
|
||||
thread.id = `t:${message.id}`
|
||||
}
|
||||
|
||||
// update the participants on the thread
|
||||
const threadParticipants = [].concat(thread.participants);
|
||||
|
|
Loading…
Reference in a new issue