mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-06 12:44:30 +08:00
[local-sync] fix(specs): New specs for threading
This commit is contained in:
parent
63032a2449
commit
269d61171a
11 changed files with 379 additions and 288 deletions
|
@ -27,7 +27,7 @@
|
|||
"vision": "4.1.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "../../../../node_modules/.bin/electron ../../../../ --test --spec-directory=$(pwd)/spec"
|
||||
"test": "../../../../node_modules/.bin/electron ../../../../ --test --enable-logging --spec-directory=$(pwd)/spec"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
----==_mimepart_576812149912_70c83ff638d112bc812dd
|
||||
Content-Type: text/plain;
|
||||
charset=UTF-8
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
> @@ -1298,3 +1298,15 @@
|
||||
> - "Unity"
|
||||
> - "Scratch"
|
||||
> icon: "gausssense.png"
|
||||
> +-
|
||||
> + name: "Jasper"
|
||||
> + description: "The GitHub Issue Reader"
|
||||
> + website: "https://jasperapp.io"
|
||||
> + repository: "https://github.com/jasperapp/jasper"
|
||||
> + license: ""
|
||||
|
||||
Oh oops, one more thing, you can also just remove this line rather than leave it empty.
|
||||
|
||||
---
|
||||
You are receiving this because you are subscribed to this thread.
|
||||
Reply to this email directly or view it on GitHub:
|
||||
https://github.com/electron/electron.atom.io/pull/352/files/c3af72fe5aea0add912cd5afe153a626619de222#r67715160
|
||||
----==_mimepart_576812149912_70c83ff638d112bc812dd
|
||||
Content-Type: text/html;
|
||||
charset=UTF-8
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
<p>In <a href="https://github.com/electron/electron.atom.io/pull/352#discussion_r67715160">_data/apps.yml</a>:</p>
|
||||
<pre style='color:#555'>> @@ -1298,3 +1298,15 @@
|
||||
> - "Unity"
|
||||
> - "Scratch"
|
||||
> icon: "gausssense.png"
|
||||
> +-
|
||||
> + name: "Jasper"
|
||||
> + description: "The GitHub Issue Reader"
|
||||
> + website: "https://jasperapp.io"
|
||||
> + repository: "https://github.com/jasperapp/jasper"
|
||||
> + license: ""
|
||||
</pre>
|
||||
<p>Oh oops, one more thing, you can also just remove this line rather than leave it empty. </p>
|
||||
|
||||
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/electron/electron.atom.io/pull/352/files/c3af72fe5aea0add912cd5afe153a626619de222#r67715160">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AA_TnJLmsKfR4hNuUZ3uUkv2iQ-_LjhEks5qNrgUgaJpZM4I5F90">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AA_TnBFImPbNv9RyTxshvjiT_cZCsVwCks5qNrgUgaJpZM4I5F90.gif" width="1" /></p>
|
||||
<div itemscope itemtype="http://schema.org/EmailMessage">
|
||||
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
|
||||
<link itemprop="url" href="https://github.com/electron/electron.atom.io/pull/352/files/c3af72fe5aea0add912cd5afe153a626619de222#r67715160"></link>
|
||||
<meta itemprop="name" content="View Pull Request"></meta>
|
||||
</div>
|
||||
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
|
||||
</div>
|
||||
|
||||
----==_mimepart_576812149912_70c83ff638d112bc812dd--
|
|
@ -1,67 +0,0 @@
|
|||
Delivered-To: bengotow@gmail.com
|
||||
Received: by 10.107.39.131 with SMTP id n125csp1566492ion; Mon, 20 Jun 2016
|
||||
08:56:06 -0700 (PDT)
|
||||
X-Received: by 10.107.175.83 with SMTP id y80mr24643127ioe.70.1466438166869;
|
||||
Mon, 20 Jun 2016 08:56:06 -0700 (PDT)
|
||||
Return-Path: <bounces+848413-92ca-bengotow=gmail.com@sgmail.github.com>
|
||||
Received: from o5.sgmail.github.com (o5.sgmail.github.com. [192.254.113.10])
|
||||
by mx.google.com with ESMTPS id g123si16992050ioe.194.2016.06.20.08.56.06 for
|
||||
<bengotow@gmail.com> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256
|
||||
bits=128/128); Mon, 20 Jun 2016 08:56:06 -0700 (PDT)
|
||||
Received-SPF: pass (google.com: best guess record for domain of
|
||||
bounces+848413-92ca-bengotow=gmail.com@sgmail.github.com designates
|
||||
192.254.113.10 as permitted sender) client-ip=192.254.113.10;
|
||||
Authentication-Results: mx.google.com; dkim=pass header.i=@github.com;
|
||||
dkim=pass header.i=@sendgrid.info; spf=pass (google.com: best guess record
|
||||
for domain of bounces+848413-92ca-bengotow=gmail.com@sgmail.github.com
|
||||
designates 192.254.113.10 as permitted sender)
|
||||
smtp.mailfrom=bounces+848413-92ca-bengotow=gmail.com@sgmail.github.com;
|
||||
dmarc=pass (p=NONE dis=NONE) header.from=github.com
|
||||
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=github.com;
|
||||
h=from:reply-to:to:cc:in-reply-to:references:subject:mime-version:content-type:content-transfer-encoding:list-id:list-archive:list-post:list-unsubscribe;
|
||||
s=s20150108; bh=5XfiJ/IF3qb2JfQruE1ZXDdHpzo=; b=pVyxGvcKaxEE3zix
|
||||
VALF4ugiEssCLrxxiuKOPttOz/WL7Xzf6wUl74cHRUbZ4ShEXT3pe8yUbiMuWJIy
|
||||
R/Kegxrf+ThIoFNNj4SLuZbtv+N7Ic2GrXZdxZLyHnR5sxNKdXk7r0Z6GkXdmavZ
|
||||
Y3GYWjJp9DO7FMFyQ88BqIPQXto=
|
||||
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.info;
|
||||
h=from:reply-to:to:cc:in-reply-to:references:subject:mime-version:content-type:content-transfer-encoding:list-id:list-archive:list-post:list-unsubscribe:x-feedback-id;
|
||||
s=smtpapi; bh=5XfiJ/IF3qb2JfQruE1ZXDdHpzo=; b=WHrBPVafQkvIJmwSPM
|
||||
SPpv2z0GcAQcM8IKTj/L4KDI92vwfoy8zclmTj+NB4XP5LH8Fcjd3Zj9yFJvb5O/
|
||||
2+ZSEhQNSg9ALStUDQuGYR0kzspSQsvncx4jI7tHZPfP2oAZkQIu4IYLjVN80IEF
|
||||
SuFzrPpitO7BmwcRSiAy7SZLI=
|
||||
Received: by filter0441p1mdw1.sendgrid.net with SMTP id
|
||||
filter0441p1mdw1.13584.5768121421 2016-06-20 15:56:04.264672456 +0000 UTC
|
||||
Received: from github-smtp2b-ext-cp1-prd.iad.github.net
|
||||
(github-smtp2b-ext-cp1-prd.iad.github.net [192.30.253.17]) by
|
||||
ismtpd0004p1iad1.sendgrid.net (SG) with ESMTP id LipJElPMRZOlYFTbOZCHmg for
|
||||
<bengotow@gmail.com>; Mon, 20 Jun 2016 15:56:04.173 +0000 (UTC)
|
||||
Date: Mon, 20 Jun 2016 08:56:04 -0700
|
||||
From: Jessica Lord <notifications@github.com>
|
||||
Reply-To: "electron/electron.atom.io"
|
||||
<reply+000fd39cefc8acddea06d083a65de369fca801b440c9cd0492cf00000001137fd41492a170ce04094058@reply.github.com>
|
||||
To: "electron/electron.atom.io" <electron.atom.io@noreply.github.com>
|
||||
Cc:
|
||||
Message-ID: <electron/electron.atom.io/pull/352/r67715160@github.com>
|
||||
In-Reply-To: <electron/electron.atom.io/pull/352@github.com>
|
||||
References: <electron/electron.atom.io/pull/352@github.com>
|
||||
Subject: Re: [electron/electron.atom.io] Add Jasper app (#352)
|
||||
Mime-Version: 1.0
|
||||
Content-Type: multipart/alternative;
|
||||
boundary="--==_mimepart_576812149912_70c83ff638d112bc812dd"; charset=UTF-8
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Precedence: list
|
||||
X-GitHub-Sender: jlord
|
||||
X-GitHub-Recipient: bengotow
|
||||
List-ID: electron/electron.atom.io <electron.atom.io.electron.github.com>
|
||||
List-Archive: https://github.com/electron/electron.atom.io
|
||||
List-Post: <mailto:reply+000fd39cefc8acddea06d083a65de369fca801b440c9cd0492cf00000001137fd41492a170ce04094058@reply.github.com>
|
||||
List-Unsubscribe: <mailto:unsub+000fd39cefc8acddea06d083a65de369fca801b440c9cd0492cf00000001137fd41492a170ce04094058@reply.github.com>,
|
||||
<https://github.com/notifications/unsubscribe/AA_TnJLmsKfR4hNuUZ3uUkv2iQ-_LjhEks5qNrgUgaJpZM4I5F90>
|
||||
X-Auto-Response-Suppress: All
|
||||
X-GitHub-Recipient-Address: bengotow@gmail.com
|
||||
X-SG-EID: zpvha59ROIAeS8NpfQSmmILEvCHiUBlaQ8TFhOrQHPl0QSHOgRoWHzGqgNGQ1PnCE+4nt5yi6b+iVd
|
||||
zi18AeK3NmcJMPjYoKBL9oylAFXcX7JSvmAI2o8GQMXjRfn6C9jjTKhzFhZ3brgLB13N+v++poucpZ
|
||||
K0ksN28YtdSO0PvYYktx2Lu+g8yKBRFzyXmcuJM5D9O3YDhd0/VRVk1WlanT5sFV/t1fjjJtGwaOvg
|
||||
4=
|
||||
X-Feedback-ID: 848413:6xvVEJqleZlAW7/vhv7PzD/cv5tamo2SWZDKyvugGvg=:6xvVEJqleZlAW7/vhv7PzD/cv5tamo2SWZDKyvugGvg=:SG
|
||||
|
53
packages/local-sync/spec/fixtures/Threading/remote-thread-id-no.js
vendored
Normal file
53
packages/local-sync/spec/fixtures/Threading/remote-thread-id-no.js
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
module.exports = {
|
||||
A: {
|
||||
id: 1,
|
||||
accountId: 'test-account-id',
|
||||
subject: "This is an email",
|
||||
body: "<head></head><body>Hi Jackie,<div><div>While browsing Nylas themes, I stumbled upon your website and looked at your work. </div><div>Great work on projects, nice to see your multidisciplinary interests :)</div><div><div><br></div><!-- <signature> -->Thanks, <div>Sagar Sutar</div><div>thesagarsutar.me</div><!-- </signature> --></div></div><img class=\"n1-open\" width=\"0\" height=\"0\" style=\"border:0; width:0; height:0;\" src=\"https://link.nylas.com/open/8w734mdm7q9ivpc0cnq3ousy3/local-7b7d5479-575c?r=amFja2llaGx1b0BnbWFpbC5jb20=\"></body>",
|
||||
headers: {
|
||||
"x-gm-thrid": "GMAILTHREAD1",
|
||||
"Delivered-To": "jackiehluo@gmail.com",
|
||||
"Date": "Fri, 17 Jun 2016 09:38:44 -0700 (PDT)",
|
||||
"Message-Id": "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
"X-Inbox-Id": "82y7eq1ipmadaxwcy6kr072bw-2147483647",
|
||||
},
|
||||
from: [{
|
||||
name: "Sagar Sutar",
|
||||
email: "<sagar_s@nid.edu>",
|
||||
}],
|
||||
to: [{
|
||||
name: "jackiehluo@gmail.com",
|
||||
email: "<jackiehluo@gmail.com>",
|
||||
}],
|
||||
cc: [],
|
||||
bcc: [],
|
||||
headerMessageId: "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
snippet: "Hi Jackie, While browsing Nylas themes, I stumbled upon your website and looked at your work. Great ",
|
||||
},
|
||||
B: {
|
||||
id: 2,
|
||||
accountId: 'test-account-id',
|
||||
subject: "This is a reply with a different subject",
|
||||
body: "<head></head><body>Sagar,<div><div><br></div><div>Aw, glad to hear it! Thanks for getting in touch!</div><br><!-- <signature> -->Jackie Luo<div>Software Engineer, Nylas</div><br><!-- </signature> --></div><div class=\"gmail_quote\">On Jun 17 2016, at 9:38 am, Sagar Sutar <sagar_s@nid.edu> wrote:<br><blockquote class=\"gmail_quote\" style=\"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;\">Hi Jackie,<div><div>While browsing Nylas themes, I stumbled upon your website and looked at your work. </div><div>Great work on projects, nice to see your multidisciplinary interests :)</div><div><div><br></div>Thanks, <div>Sagar Sutar</div><div>thesagarsutar.me</div></div></div><img width=\"0\" height=\"0\" style=\"border:0; width:0; height:0;\" src=\"https://link.nylas.com/open/8w734mdm7q9ivpc0cnq3ousy3/local-7b7d5479-575c?r=amFja2llaGx1b0BnbWFpbC5jb20=\"></blockquote></div></body>",
|
||||
headers: {
|
||||
"x-gm-thrid": "GMAILTHREAD2",
|
||||
"Date": "Fri, 17 Jun 2016 18:20:47 +0000",
|
||||
"References": "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
"In-Reply-To": "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
"Message-Id": "<cq08iqwatp00kai4qnff7zbaj-2147483647@mailer.nylas.com>",
|
||||
"X-Inbox-Id": "cq08iqwatp00kai4qnff7zbaj-2147483647",
|
||||
},
|
||||
from: [{
|
||||
name: "Jackie Luo",
|
||||
email: "<jackiehluo@gmail.com>",
|
||||
}],
|
||||
to: [{
|
||||
name: "Sagar Sutar",
|
||||
email: "<sagar_s@nid.edu>",
|
||||
}],
|
||||
cc: [],
|
||||
bcc: [],
|
||||
headerMessageId: "<cq08iqwatp00kai4qnff7zbaj-2147483647@mailer.nylas.com>",
|
||||
snippet: "Sagar, Aw, glad to hear it! Thanks for getting in touch! Jackie Luo Software Engineer, Nylas",
|
||||
},
|
||||
};
|
53
packages/local-sync/spec/fixtures/Threading/remote-thread-id-yes.js
vendored
Normal file
53
packages/local-sync/spec/fixtures/Threading/remote-thread-id-yes.js
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
module.exports = {
|
||||
A: {
|
||||
id: 1,
|
||||
accountId: 'test-account-id',
|
||||
subject: "This is an email",
|
||||
body: "<head></head><body>Hi Jackie,<div><div>While browsing Nylas themes, I stumbled upon your website and looked at your work. </div><div>Great work on projects, nice to see your multidisciplinary interests :)</div><div><div><br></div><!-- <signature> -->Thanks, <div>Sagar Sutar</div><div>thesagarsutar.me</div><!-- </signature> --></div></div><img class=\"n1-open\" width=\"0\" height=\"0\" style=\"border:0; width:0; height:0;\" src=\"https://link.nylas.com/open/8w734mdm7q9ivpc0cnq3ousy3/local-7b7d5479-575c?r=amFja2llaGx1b0BnbWFpbC5jb20=\"></body>",
|
||||
headers: {
|
||||
"x-gm-thrid": "GMAILTHREAD1",
|
||||
"Delivered-To": "jackiehluo@gmail.com",
|
||||
"Date": "Fri, 17 Jun 2016 09:38:44 -0700 (PDT)",
|
||||
"Message-Id": "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
"X-Inbox-Id": "82y7eq1ipmadaxwcy6kr072bw-2147483647",
|
||||
},
|
||||
from: [{
|
||||
name: "Sagar Sutar",
|
||||
email: "<sagar_s@nid.edu>",
|
||||
}],
|
||||
to: [{
|
||||
name: "jackiehluo@gmail.com",
|
||||
email: "<jackiehluo@gmail.com>",
|
||||
}],
|
||||
cc: [],
|
||||
bcc: [],
|
||||
headerMessageId: "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
snippet: "Hi Jackie, While browsing Nylas themes, I stumbled upon your website and looked at your work. Great ",
|
||||
},
|
||||
B: {
|
||||
id: 2,
|
||||
accountId: 'test-account-id',
|
||||
subject: "This is a reply with a different subject",
|
||||
body: "<head></head><body>Sagar,<div><div><br></div><div>Aw, glad to hear it! Thanks for getting in touch!</div><br><!-- <signature> -->Jackie Luo<div>Software Engineer, Nylas</div><br><!-- </signature> --></div><div class=\"gmail_quote\">On Jun 17 2016, at 9:38 am, Sagar Sutar <sagar_s@nid.edu> wrote:<br><blockquote class=\"gmail_quote\" style=\"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;\">Hi Jackie,<div><div>While browsing Nylas themes, I stumbled upon your website and looked at your work. </div><div>Great work on projects, nice to see your multidisciplinary interests :)</div><div><div><br></div>Thanks, <div>Sagar Sutar</div><div>thesagarsutar.me</div></div></div><img width=\"0\" height=\"0\" style=\"border:0; width:0; height:0;\" src=\"https://link.nylas.com/open/8w734mdm7q9ivpc0cnq3ousy3/local-7b7d5479-575c?r=amFja2llaGx1b0BnbWFpbC5jb20=\"></blockquote></div></body>",
|
||||
headers: {
|
||||
"x-gm-thrid": "GMAILTHREAD1",
|
||||
"Date": "Fri, 17 Jun 2016 18:20:47 +0000",
|
||||
"References": "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
"In-Reply-To": "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
"Message-Id": "<cq08iqwatp00kai4qnff7zbaj-2147483647@mailer.nylas.com>",
|
||||
"X-Inbox-Id": "cq08iqwatp00kai4qnff7zbaj-2147483647",
|
||||
},
|
||||
from: [{
|
||||
name: "Jackie Luo",
|
||||
email: "<jackiehluo@gmail.com>",
|
||||
}],
|
||||
to: [{
|
||||
name: "Sagar Sutar",
|
||||
email: "<sagar_s@nid.edu>",
|
||||
}],
|
||||
cc: [],
|
||||
bcc: [],
|
||||
headerMessageId: "<cq08iqwatp00kai4qnff7zbaj-2147483647@mailer.nylas.com>",
|
||||
snippet: "Sagar, Aw, glad to hear it! Thanks for getting in touch! Jackie Luo Software Engineer, Nylas",
|
||||
},
|
||||
};
|
78
packages/local-sync/spec/fixtures/Threading/subject-matching-no.js
vendored
Normal file
78
packages/local-sync/spec/fixtures/Threading/subject-matching-no.js
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
module.exports = {
|
||||
A: {
|
||||
id: 1,
|
||||
accountId: 'test-account-id',
|
||||
subject: "Loved your work and interests",
|
||||
body: "<head></head><body>Hi Jackie,<div><div>While browsing Nylas themes, I stumbled upon your website and looked at your work. </div><div>Great work on projects, nice to see your multidisciplinary interests :)</div><div><div><br></div><!-- <signature> -->Thanks, <div>Sagar Sutar</div><div>thesagarsutar.me</div><!-- </signature> --></div></div><img class=\"n1-open\" width=\"0\" height=\"0\" style=\"border:0; width:0; height:0;\" src=\"https://link.nylas.com/open/8w734mdm7q9ivpc0cnq3ousy3/local-7b7d5479-575c?r=amFja2llaGx1b0BnbWFpbC5jb20=\"></body>",
|
||||
headers: {
|
||||
"Delivered-To": "jackiehluo@gmail.com",
|
||||
"Received-SPF": `pass (google.com: domain of sagy26.1991@gmail.com
|
||||
designates 209.85.192.174 as permitted sender) client-ip=209.85.192.174;`,
|
||||
"Authentication-Results": `mx.google.com;
|
||||
spf=pass (google.com: domain of sagy26.1991@gmail.com designates
|
||||
209.85.192.174 as permitted sender) smtp.mailfrom=sagy26.1991@gmail.com`,
|
||||
"X-Google-DKIM-Signature": `v=1; a=rsa-sha256; c=relaxed/relaxed;
|
||||
d=1e100.net; s=20130820;
|
||||
h=x-gm-message-state:date:user-agent:message-id:to:from:subject
|
||||
:mime-version;
|
||||
bh=to3fCB9g4R6V18kpAAKSAlUeTC+N0rg4JckFbiaILA4=;
|
||||
b=WfI5viTYPjviUur9Bd2rJQfpHxIm2xYRdxrN64bJGuX0TQlb7p8bDvCBNNhY3mTXJx
|
||||
lsQzRX9RA4FMuDk0oz0mpviWtkpkZsDeyjpSmA+ONcPgdyPAezzPDvSWRzMZY21fiHxS
|
||||
hr4I5AeFKesGcbvwtJu+S0fMGhdveC8E35oTA010Xfave6Xd55qGXy7hW+4xCfvIesy4
|
||||
01oOaXWDmLHqixKO3SXwmGCcDzqn/IKXhB7UXkF0efSTwh8yid6v9iXdW+ovJ2qg9peI
|
||||
HSnPIilYk8SaKoPdGDgYZykfUIgNrSugtK/vvGG2aN+9lhURxPfzhniWdNqdsgR7G4E7
|
||||
7XqA==`,
|
||||
"X-Gm-Message-State": "ALyK8tIf7XyYaylyVf0qjzh8rhYz3rj/VQYaNLDjVq5ESH19ioJIgW7o9FbghP+wFYrBuw==",
|
||||
"X-Received": `by 10.98.111.138 with SMTP id k132mr3246291pfc.105.1466181525186;
|
||||
Fri, 17 Jun 2016 09:38:45 -0700 (PDT)`,
|
||||
"Return-Path": "<sagy26.1991@gmail.com>",
|
||||
"Received": `from [127.0.0.1] (ec2-52-36-99-221.us-west-2.compute.amazonaws.com. [52.36.99.221])
|
||||
by smtp.gmail.com with ESMTPSA id d69sm64179062pfj.31.2016.06.17.09.38.44
|
||||
for <jackiehluo@gmail.com>
|
||||
(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
|
||||
Fri, 17 Jun 2016 09:38:44 -0700 (PDT)`,
|
||||
"Date": "Fri, 17 Jun 2016 09:38:44 -0700 (PDT)",
|
||||
"User-Agent": "NylasMailer/0.4",
|
||||
"Message-Id": "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
"X-Inbox-Id": "82y7eq1ipmadaxwcy6kr072bw-2147483647",
|
||||
},
|
||||
from: [{
|
||||
name: "Sagar Sutar",
|
||||
email: "<sagar_s@nid.edu>",
|
||||
}],
|
||||
to: [{
|
||||
name: "jackiehluo@gmail.com",
|
||||
email: "<jackiehluo@gmail.com>",
|
||||
}],
|
||||
cc: [],
|
||||
bcc: [],
|
||||
headerMessageId: "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
snippet: "Hi Jackie, While browsing Nylas themes, I stumbled upon your website and looked at your work. Great ",
|
||||
},
|
||||
B: {
|
||||
id: 2,
|
||||
accountId: 'test-account-id',
|
||||
subject: "Re: Another unrelated email",
|
||||
body: "<head></head><body>Sagar,<div><div><br></div><div>Aw, glad to hear it! Thanks for getting in touch!</div><br><!-- <signature> -->Jackie Luo<div>Software Engineer, Nylas</div><br><!-- </signature> --></div><div class=\"gmail_quote\">On Jun 17 2016, at 9:38 am, Sagar Sutar <sagar_s@nid.edu> wrote:<br><blockquote class=\"gmail_quote\" style=\"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;\">Hi Jackie,<div><div>While browsing Nylas themes, I stumbled upon your website and looked at your work. </div><div>Great work on projects, nice to see your multidisciplinary interests :)</div><div><div><br></div>Thanks, <div>Sagar Sutar</div><div>thesagarsutar.me</div></div></div><img width=\"0\" height=\"0\" style=\"border:0; width:0; height:0;\" src=\"https://link.nylas.com/open/8w734mdm7q9ivpc0cnq3ousy3/local-7b7d5479-575c?r=amFja2llaGx1b0BnbWFpbC5jb20=\"></blockquote></div></body>",
|
||||
headers: {
|
||||
"Date": "Fri, 17 Jun 2016 18:20:47 +0000",
|
||||
"References": "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
"In-Reply-To": "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
"User-Agent": "NylasMailer/0.4",
|
||||
"Message-Id": "<cq08iqwatp00kai4qnff7zbaj-2147483647@mailer.nylas.com>",
|
||||
"X-Inbox-Id": "cq08iqwatp00kai4qnff7zbaj-2147483647",
|
||||
},
|
||||
from: [{
|
||||
name: "Jackie Luo",
|
||||
email: "<jackiehluo@gmail.com>",
|
||||
}],
|
||||
to: [{
|
||||
name: "Sagar Sutar",
|
||||
email: "<sagar_s@nid.edu>",
|
||||
}],
|
||||
cc: [],
|
||||
bcc: [],
|
||||
headerMessageId: "<cq08iqwatp00kai4qnff7zbaj-2147483647@mailer.nylas.com>",
|
||||
snippet: "Sagar, Aw, glad to hear it! Thanks for getting in touch! Jackie Luo Software Engineer, Nylas",
|
||||
},
|
||||
};
|
78
packages/local-sync/spec/fixtures/Threading/subject-matching-yes.js
vendored
Normal file
78
packages/local-sync/spec/fixtures/Threading/subject-matching-yes.js
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
module.exports = {
|
||||
A: {
|
||||
id: 1,
|
||||
accountId: 'test-account-id',
|
||||
subject: "Loved your work and interests",
|
||||
body: "<head></head><body>Hi Jackie,<div><div>While browsing Nylas themes, I stumbled upon your website and looked at your work. </div><div>Great work on projects, nice to see your multidisciplinary interests :)</div><div><div><br></div><!-- <signature> -->Thanks, <div>Sagar Sutar</div><div>thesagarsutar.me</div><!-- </signature> --></div></div><img class=\"n1-open\" width=\"0\" height=\"0\" style=\"border:0; width:0; height:0;\" src=\"https://link.nylas.com/open/8w734mdm7q9ivpc0cnq3ousy3/local-7b7d5479-575c?r=amFja2llaGx1b0BnbWFpbC5jb20=\"></body>",
|
||||
headers: {
|
||||
"Delivered-To": "jackiehluo@gmail.com",
|
||||
"Received-SPF": `pass (google.com: domain of sagy26.1991@gmail.com
|
||||
designates 209.85.192.174 as permitted sender) client-ip=209.85.192.174;`,
|
||||
"Authentication-Results": `mx.google.com;
|
||||
spf=pass (google.com: domain of sagy26.1991@gmail.com designates
|
||||
209.85.192.174 as permitted sender) smtp.mailfrom=sagy26.1991@gmail.com`,
|
||||
"X-Google-DKIM-Signature": `v=1; a=rsa-sha256; c=relaxed/relaxed;
|
||||
d=1e100.net; s=20130820;
|
||||
h=x-gm-message-state:date:user-agent:message-id:to:from:subject
|
||||
:mime-version;
|
||||
bh=to3fCB9g4R6V18kpAAKSAlUeTC+N0rg4JckFbiaILA4=;
|
||||
b=WfI5viTYPjviUur9Bd2rJQfpHxIm2xYRdxrN64bJGuX0TQlb7p8bDvCBNNhY3mTXJx
|
||||
lsQzRX9RA4FMuDk0oz0mpviWtkpkZsDeyjpSmA+ONcPgdyPAezzPDvSWRzMZY21fiHxS
|
||||
hr4I5AeFKesGcbvwtJu+S0fMGhdveC8E35oTA010Xfave6Xd55qGXy7hW+4xCfvIesy4
|
||||
01oOaXWDmLHqixKO3SXwmGCcDzqn/IKXhB7UXkF0efSTwh8yid6v9iXdW+ovJ2qg9peI
|
||||
HSnPIilYk8SaKoPdGDgYZykfUIgNrSugtK/vvGG2aN+9lhURxPfzhniWdNqdsgR7G4E7
|
||||
7XqA==`,
|
||||
"X-Gm-Message-State": "ALyK8tIf7XyYaylyVf0qjzh8rhYz3rj/VQYaNLDjVq5ESH19ioJIgW7o9FbghP+wFYrBuw==",
|
||||
"X-Received": `by 10.98.111.138 with SMTP id k132mr3246291pfc.105.1466181525186;
|
||||
Fri, 17 Jun 2016 09:38:45 -0700 (PDT)`,
|
||||
"Return-Path": "<sagy26.1991@gmail.com>",
|
||||
"Received": `from [127.0.0.1] (ec2-52-36-99-221.us-west-2.compute.amazonaws.com. [52.36.99.221])
|
||||
by smtp.gmail.com with ESMTPSA id d69sm64179062pfj.31.2016.06.17.09.38.44
|
||||
for <jackiehluo@gmail.com>
|
||||
(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
|
||||
Fri, 17 Jun 2016 09:38:44 -0700 (PDT)`,
|
||||
"Date": "Fri, 17 Jun 2016 09:38:44 -0700 (PDT)",
|
||||
"User-Agent": "NylasMailer/0.4",
|
||||
"Message-Id": "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
"X-Inbox-Id": "82y7eq1ipmadaxwcy6kr072bw-2147483647",
|
||||
},
|
||||
from: [{
|
||||
name: "Sagar Sutar",
|
||||
email: "<sagar_s@nid.edu>",
|
||||
}],
|
||||
to: [{
|
||||
name: "jackiehluo@gmail.com",
|
||||
email: "<jackiehluo@gmail.com>",
|
||||
}],
|
||||
cc: [],
|
||||
bcc: [],
|
||||
headerMessageId: "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
snippet: "Hi Jackie, While browsing Nylas themes, I stumbled upon your website and looked at your work. Great ",
|
||||
},
|
||||
B: {
|
||||
id: 2,
|
||||
accountId: 'test-account-id',
|
||||
subject: "Re: Loved your work and interests",
|
||||
body: "<head></head><body>Sagar,<div><div><br></div><div>Aw, glad to hear it! Thanks for getting in touch!</div><br><!-- <signature> -->Jackie Luo<div>Software Engineer, Nylas</div><br><!-- </signature> --></div><div class=\"gmail_quote\">On Jun 17 2016, at 9:38 am, Sagar Sutar <sagar_s@nid.edu> wrote:<br><blockquote class=\"gmail_quote\" style=\"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;\">Hi Jackie,<div><div>While browsing Nylas themes, I stumbled upon your website and looked at your work. </div><div>Great work on projects, nice to see your multidisciplinary interests :)</div><div><div><br></div>Thanks, <div>Sagar Sutar</div><div>thesagarsutar.me</div></div></div><img width=\"0\" height=\"0\" style=\"border:0; width:0; height:0;\" src=\"https://link.nylas.com/open/8w734mdm7q9ivpc0cnq3ousy3/local-7b7d5479-575c?r=amFja2llaGx1b0BnbWFpbC5jb20=\"></blockquote></div></body>",
|
||||
headers: {
|
||||
"Date": "Fri, 17 Jun 2016 18:20:47 +0000",
|
||||
"References": "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
"In-Reply-To": "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
"User-Agent": "NylasMailer/0.4",
|
||||
"Message-Id": "<cq08iqwatp00kai4qnff7zbaj-2147483647@mailer.nylas.com>",
|
||||
"X-Inbox-Id": "cq08iqwatp00kai4qnff7zbaj-2147483647",
|
||||
},
|
||||
from: [{
|
||||
name: "Jackie Luo",
|
||||
email: "<jackiehluo@gmail.com>",
|
||||
}],
|
||||
to: [{
|
||||
name: "Sagar Sutar",
|
||||
email: "<sagar_s@nid.edu>",
|
||||
}],
|
||||
cc: [],
|
||||
bcc: [],
|
||||
headerMessageId: "<cq08iqwatp00kai4qnff7zbaj-2147483647@mailer.nylas.com>",
|
||||
snippet: "Sagar, Aw, glad to hear it! Thanks for getting in touch! Jackie Luo Software Engineer, Nylas",
|
||||
},
|
||||
};
|
81
packages/local-sync/spec/fixtures/thread.js
vendored
81
packages/local-sync/spec/fixtures/thread.js
vendored
|
@ -1,81 +0,0 @@
|
|||
export const message = {
|
||||
id: 1,
|
||||
subject: "Loved your work and interests",
|
||||
body: "<head></head><body>Hi Jackie,<div><div>While browsing Nylas themes, I stumbled upon your website and looked at your work. </div><div>Great work on projects, nice to see your multidisciplinary interests :)</div><div><div><br></div><!-- <signature> -->Thanks, <div>Sagar Sutar</div><div>thesagarsutar.me</div><!-- </signature> --></div></div><img class=\"n1-open\" width=\"0\" height=\"0\" style=\"border:0; width:0; height:0;\" src=\"https://link.nylas.com/open/8w734mdm7q9ivpc0cnq3ousy3/local-7b7d5479-575c?r=amFja2llaGx1b0BnbWFpbC5jb20=\"></body>",
|
||||
headers: {
|
||||
"Delivered-To": "jackiehluo@gmail.com",
|
||||
"Received-SPF": `pass (google.com: domain of sagy26.1991@gmail.com
|
||||
designates 209.85.192.174 as permitted sender) client-ip=209.85.192.174;`,
|
||||
"Authentication-Results": `mx.google.com;
|
||||
spf=pass (google.com: domain of sagy26.1991@gmail.com designates
|
||||
209.85.192.174 as permitted sender) smtp.mailfrom=sagy26.1991@gmail.com`,
|
||||
"X-Google-DKIM-Signature": `v=1; a=rsa-sha256; c=relaxed/relaxed;
|
||||
d=1e100.net; s=20130820;
|
||||
h=x-gm-message-state:date:user-agent:message-id:to:from:subject
|
||||
:mime-version;
|
||||
bh=to3fCB9g4R6V18kpAAKSAlUeTC+N0rg4JckFbiaILA4=;
|
||||
b=WfI5viTYPjviUur9Bd2rJQfpHxIm2xYRdxrN64bJGuX0TQlb7p8bDvCBNNhY3mTXJx
|
||||
lsQzRX9RA4FMuDk0oz0mpviWtkpkZsDeyjpSmA+ONcPgdyPAezzPDvSWRzMZY21fiHxS
|
||||
hr4I5AeFKesGcbvwtJu+S0fMGhdveC8E35oTA010Xfave6Xd55qGXy7hW+4xCfvIesy4
|
||||
01oOaXWDmLHqixKO3SXwmGCcDzqn/IKXhB7UXkF0efSTwh8yid6v9iXdW+ovJ2qg9peI
|
||||
HSnPIilYk8SaKoPdGDgYZykfUIgNrSugtK/vvGG2aN+9lhURxPfzhniWdNqdsgR7G4E7
|
||||
7XqA==`,
|
||||
"X-Gm-Message-State": "ALyK8tIf7XyYaylyVf0qjzh8rhYz3rj/VQYaNLDjVq5ESH19ioJIgW7o9FbghP+wFYrBuw==",
|
||||
"X-Received": `by 10.98.111.138 with SMTP id k132mr3246291pfc.105.1466181525186;
|
||||
Fri, 17 Jun 2016 09:38:45 -0700 (PDT)`,
|
||||
"Return-Path": "<sagy26.1991@gmail.com>",
|
||||
"Received": `from [127.0.0.1] (ec2-52-36-99-221.us-west-2.compute.amazonaws.com. [52.36.99.221])
|
||||
by smtp.gmail.com with ESMTPSA id d69sm64179062pfj.31.2016.06.17.09.38.44
|
||||
for <jackiehluo@gmail.com>
|
||||
(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
|
||||
Fri, 17 Jun 2016 09:38:44 -0700 (PDT)`,
|
||||
"Date": "Fri, 17 Jun 2016 09:38:44 -0700 (PDT)",
|
||||
"User-Agent": "NylasMailer/0.4",
|
||||
"Message-Id": "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
"X-Inbox-Id": "82y7eq1ipmadaxwcy6kr072bw-2147483647",
|
||||
},
|
||||
from: [{
|
||||
name: "Sagar Sutar",
|
||||
email: "<sagar_s@nid.edu>",
|
||||
}],
|
||||
to: [{
|
||||
name: "jackiehluo@gmail.com",
|
||||
email: "<jackiehluo@gmail.com>",
|
||||
}],
|
||||
cc: [],
|
||||
bcc: [],
|
||||
headerMessageId: "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
snippet: "Hi Jackie, While browsing Nylas themes, I stumbled upon your website and looked at your work. Great ",
|
||||
setThread: (thread) => {
|
||||
message.thread = thread.id
|
||||
},
|
||||
}
|
||||
|
||||
export const reply = {
|
||||
id: 2,
|
||||
subject: "Re: Loved your work and interests",
|
||||
body: "<head></head><body>Sagar,<div><div><br></div><div>Aw, glad to hear it! Thanks for getting in touch!</div><br><!-- <signature> -->Jackie Luo<div>Software Engineer, Nylas</div><br><!-- </signature> --></div><div class=\"gmail_quote\">On Jun 17 2016, at 9:38 am, Sagar Sutar <sagar_s@nid.edu> wrote:<br><blockquote class=\"gmail_quote\" style=\"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;\">Hi Jackie,<div><div>While browsing Nylas themes, I stumbled upon your website and looked at your work. </div><div>Great work on projects, nice to see your multidisciplinary interests :)</div><div><div><br></div>Thanks, <div>Sagar Sutar</div><div>thesagarsutar.me</div></div></div><img width=\"0\" height=\"0\" style=\"border:0; width:0; height:0;\" src=\"https://link.nylas.com/open/8w734mdm7q9ivpc0cnq3ousy3/local-7b7d5479-575c?r=amFja2llaGx1b0BnbWFpbC5jb20=\"></blockquote></div></body>",
|
||||
headers: {
|
||||
"Date": "Fri, 17 Jun 2016 18:20:47 +0000",
|
||||
"References": "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
"In-Reply-To": "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>",
|
||||
"User-Agent": "NylasMailer/0.4",
|
||||
"Message-Id": "<cq08iqwatp00kai4qnff7zbaj-2147483647@mailer.nylas.com>",
|
||||
"X-Inbox-Id": "cq08iqwatp00kai4qnff7zbaj-2147483647",
|
||||
},
|
||||
from: [{
|
||||
name: "Jackie Luo",
|
||||
email: "<jackiehluo@gmail.com>",
|
||||
}],
|
||||
to: [{
|
||||
name: "Sagar Sutar",
|
||||
email: "<sagar_s@nid.edu>",
|
||||
}],
|
||||
cc: [],
|
||||
bcc: [],
|
||||
headerMessageId: "<cq08iqwatp00kai4qnff7zbaj-2147483647@mailer.nylas.com>",
|
||||
snippet: "Sagar, Aw, glad to hear it! Thanks for getting in touch! Jackie Luo Software Engineer, Nylas",
|
||||
setThread: (thread) => {
|
||||
reply.thread = thread.id
|
||||
},
|
||||
}
|
|
@ -1,55 +1,81 @@
|
|||
/* eslint global-require: 0 */
|
||||
/* eslint import/no-dynamic-require: 0 */
|
||||
// const path = require('path')
|
||||
// const BASE_PATH = path.join(__dirname, 'fixtures')
|
||||
const path = require('path');
|
||||
const detectThread = require('../src/new-message-processor/detect-thread');
|
||||
const LocalDatabaseConnector = require('../src/shared/local-database-connector');
|
||||
|
||||
xdescribe('threading', function threadingSpecs() {
|
||||
// it('adds the message to the thread', (done) => {
|
||||
// const {message, reply} = require(`${BASE_PATH}/thread`)
|
||||
// const accountId = 'a-1'
|
||||
// const mockDb = {
|
||||
// Thread: {
|
||||
// findAll: () => {
|
||||
// return Promise.resolve([{
|
||||
// id: 1,
|
||||
// subject: "Loved your work and interests",
|
||||
// messages: [message],
|
||||
// }])
|
||||
// },
|
||||
// find: () => {
|
||||
// return Promise.resolve(null)
|
||||
// },
|
||||
// create: (thread) => {
|
||||
// thread.id = 1
|
||||
// thread.addMessage = (newMessage) => {
|
||||
// if (thread.messages) {
|
||||
// thread.messages.push(newMessage.id)
|
||||
// } else {
|
||||
// thread.messages = [newMessage.id]
|
||||
// }
|
||||
// }
|
||||
// return Promise.resolve(thread)
|
||||
// },
|
||||
// },
|
||||
// Message: {
|
||||
// findAll: () => {
|
||||
// return Promise.resolve([message, reply])
|
||||
// },
|
||||
// find: () => {
|
||||
// return Promise.resolve(reply)
|
||||
// },
|
||||
// create: () => {
|
||||
// message.setThread = (thread) => {
|
||||
// message.thread = thread.id
|
||||
// };
|
||||
// return Promise.resolve(message);
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// processMessage({db: mockDb, message: reply, accountId}).then((processed) => {
|
||||
// expect(processed.thread).toBe(1)
|
||||
// done()
|
||||
// })
|
||||
// });
|
||||
const FIXTURES_PATH = path.join(__dirname, 'fixtures');
|
||||
const ACCOUNT_ID = 'test-account-threading';
|
||||
|
||||
function messagesFromFixture({Message}, folder, name) {
|
||||
const {A, B} = require(`${FIXTURES_PATH}/Threading/${name}`)
|
||||
|
||||
const msgA = Message.build(A);
|
||||
msgA.folder = folder;
|
||||
msgA.labels = [];
|
||||
|
||||
const msgB = Message.build(B);
|
||||
msgB.folder = folder;
|
||||
msgB.labels = [];
|
||||
|
||||
return {msgA, msgB};
|
||||
}
|
||||
|
||||
describe('threading', function threadingSpecs() {
|
||||
beforeEach(() => {
|
||||
waitsForPromise({timeout: 1000}, async () => {
|
||||
await LocalDatabaseConnector.ensureAccountDatabase(ACCOUNT_ID);
|
||||
this.db = await LocalDatabaseConnector.forAccount(ACCOUNT_ID);
|
||||
this.folder = await this.db.Folder.create({
|
||||
id: 'test-folder-id',
|
||||
accountId: ACCOUNT_ID,
|
||||
version: 1,
|
||||
name: 'Test Folder',
|
||||
role: null,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
LocalDatabaseConnector.destroyAccountDatabase(ACCOUNT_ID)
|
||||
})
|
||||
|
||||
describe("when remote thread ids are present", () => {
|
||||
it('threads emails with the same gthreadid', () => {
|
||||
waitsForPromise(async () => {
|
||||
const {msgA, msgB} = messagesFromFixture(this.db, this.folder, 'remote-thread-id-yes');
|
||||
const threadA = await detectThread({db: this.db, message: msgA});
|
||||
const threadB = await detectThread({db: this.db, message: msgB});
|
||||
expect(threadB.id).toEqual(threadA.id);
|
||||
});
|
||||
});
|
||||
|
||||
it('does not thread other emails', () => {
|
||||
waitsForPromise(async () => {
|
||||
const {msgA, msgB} = messagesFromFixture(this.db, this.folder, 'remote-thread-id-no');
|
||||
const threadA = await detectThread({db: this.db, message: msgA});
|
||||
const threadB = await detectThread({db: this.db, message: msgB});
|
||||
expect(threadB.id).not.toEqual(threadA.id);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe("when subject matching", () => {
|
||||
it('threads emails with the same subject', () => {
|
||||
waitsForPromise(async () => {
|
||||
const {msgA, msgB} = messagesFromFixture(this.db, this.folder, 'subject-matching-yes');
|
||||
const threadA = await detectThread({db: this.db, message: msgA});
|
||||
const threadB = await detectThread({db: this.db, message: msgB});
|
||||
expect(threadB.id).toEqual(threadA.id);
|
||||
});
|
||||
});
|
||||
|
||||
it('does not thread other emails', () => {
|
||||
waitsForPromise(async () => {
|
||||
const {msgA, msgB} = messagesFromFixture(this.db, this.folder, 'subject-matching-no');
|
||||
const threadA = await detectThread({db: this.db, message: msgA});
|
||||
const threadB = await detectThread({db: this.db, message: msgB});
|
||||
expect(threadB.id).not.toEqual(threadA.id);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -36,10 +36,10 @@ function emptyThread({Thread, accountId}, options = {}) {
|
|||
t.folders = [];
|
||||
t.labels = [];
|
||||
t.participants = [];
|
||||
return Promise.resolve(t)
|
||||
return t;
|
||||
}
|
||||
|
||||
function findOrBuildByMatching(db, message) {
|
||||
async function findOrBuildByMatching(db, message) {
|
||||
const {Thread, Label, Folder} = db
|
||||
|
||||
// in the future, we should look at In-reply-to. Problem is it's a single-
|
||||
|
@ -47,7 +47,7 @@ function findOrBuildByMatching(db, message) {
|
|||
// but from newest->oldest, so when we ingest a message it's very unlikely
|
||||
// we have the "In-reply-to" message yet.
|
||||
|
||||
return Thread.findAll({
|
||||
const possibleThreads = await Thread.findAll({
|
||||
where: {
|
||||
subject: cleanSubject(message.subject),
|
||||
},
|
||||
|
@ -56,56 +56,54 @@ function findOrBuildByMatching(db, message) {
|
|||
],
|
||||
limit: 10,
|
||||
include: [{model: Label}, {model: Folder}],
|
||||
}).then((threads) =>
|
||||
pickMatchingThread(message, threads) || emptyThread(db, {})
|
||||
)
|
||||
});
|
||||
|
||||
return pickMatchingThread(message, possibleThreads) || emptyThread(db, {});
|
||||
}
|
||||
|
||||
function findOrBuildByRemoteThreadId(db, remoteThreadId) {
|
||||
async function findOrBuildByRemoteThreadId(db, remoteThreadId) {
|
||||
const {Thread, Label, Folder} = db;
|
||||
return Thread.find({
|
||||
const existing = await Thread.find({
|
||||
where: {remoteThreadId},
|
||||
include: [{model: Label}, {model: Folder}],
|
||||
}).then((thread) => {
|
||||
return thread || emptyThread(db, {remoteThreadId})
|
||||
})
|
||||
});
|
||||
return existing || emptyThread(db, {remoteThreadId});
|
||||
}
|
||||
|
||||
function detectThread({db, message}) {
|
||||
async function detectThread({db, message}) {
|
||||
if (!(message.labels instanceof Array)) {
|
||||
throw new Error("Threading processMessage expects labels to be an inflated array.");
|
||||
throw new Error("detectThread expects labels to be an inflated array.");
|
||||
}
|
||||
if (!message.folder) {
|
||||
throw new Error("Threading processMessage expects folder value to be present.");
|
||||
throw new Error("detectThread expects folder value to be present.");
|
||||
}
|
||||
|
||||
let findOrBuildThread = null;
|
||||
let thread = null;
|
||||
if (message.headers['x-gm-thrid']) {
|
||||
findOrBuildThread = findOrBuildByRemoteThreadId(db, message.headers['x-gm-thrid'])
|
||||
thread = await findOrBuildByRemoteThreadId(db, message.headers['x-gm-thrid'])
|
||||
} else {
|
||||
findOrBuildThread = findOrBuildByMatching(db, message)
|
||||
thread = await findOrBuildByMatching(db, message)
|
||||
}
|
||||
|
||||
return findOrBuildThread.then((thread) => {
|
||||
if (!(thread.labels instanceof Array)) {
|
||||
throw new Error("Threading processMessage expects thread.labels to be an inflated array.");
|
||||
}
|
||||
if (!(thread.folders instanceof Array)) {
|
||||
throw new Error("Threading processMessage expects thread.folders to be an inflated array.");
|
||||
}
|
||||
if (!(thread.labels instanceof Array)) {
|
||||
throw new Error("detectThread expects thread.labels to be an inflated array.");
|
||||
}
|
||||
if (!(thread.folders instanceof Array)) {
|
||||
throw new Error("detectThread expects thread.folders to be an inflated array.");
|
||||
}
|
||||
|
||||
// update the basic properties of the thread
|
||||
thread.accountId = message.accountId;
|
||||
// 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}`
|
||||
}
|
||||
// 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}`
|
||||
}
|
||||
|
||||
thread.subject = cleanSubject(message.subject);
|
||||
return thread.updateFromMessage(message);
|
||||
});
|
||||
thread.subject = cleanSubject(message.subject);
|
||||
await thread.updateFromMessage(message);
|
||||
return thread;
|
||||
}
|
||||
|
||||
module.exports = detectThread
|
||||
|
|
|
@ -66,9 +66,13 @@ class LocalDatabaseConnector {
|
|||
const dbname = `a-${accountId}`;
|
||||
const dbpath = path.join(process.env.NYLAS_HOME, `${dbname}.sqlite`);
|
||||
|
||||
const err = fs.accessSync(dbpath, fs.F_OK);
|
||||
if (!err) {
|
||||
fs.unlinkSync(dbpath);
|
||||
try {
|
||||
const err = fs.accessSync(dbpath, fs.F_OK);
|
||||
if (!err) {
|
||||
fs.unlinkSync(dbpath);
|
||||
}
|
||||
} catch (err) {
|
||||
// Ignored
|
||||
}
|
||||
|
||||
delete this._cache[accountId];
|
||||
|
|
Loading…
Add table
Reference in a new issue