Skip to content

Commit 8c7cf27

Browse files
authored
Merge pull request #987 from elie222/fix/skip-cold-email-outlook
2 parents 45e6d8b + de1a94a commit 8c7cf27

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

apps/web/utils/email/microsoft.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,17 +1186,16 @@ export class OutlookProvider implements EmailProvider {
11861186
.getClient()
11871187
.api("/me/messages")
11881188
.filter(
1189-
`from/emailAddress/address eq '${escapeODataString(options.from)}' and receivedDateTime lt ${options.date.toISOString()}`,
1189+
`(toRecipients/any(a:a/emailAddress/address eq '${escapeODataString(options.from)}') and sentDateTime lt ${options.date.toISOString()}) or (from/emailAddress/address eq '${escapeODataString(options.from)}' and receivedDateTime lt ${options.date.toISOString()})`,
11901190
)
11911191
.top(2)
11921192
.select("id")
11931193
.get();
11941194

1195-
// Check if there are any messages from this sender before the current date
1196-
// and exclude the current message
1197-
const hasPreviousEmail = response.value.some(
1198-
(message) => message.id !== options.messageId,
1199-
);
1195+
// If we have any outgoing emails, or any incoming emails (excluding current message)
1196+
const hasPreviousEmail =
1197+
response.value.length > 0 &&
1198+
response.value.some((message) => message.id !== options.messageId);
12001199

12011200
return hasPreviousEmail;
12021201
} catch (error) {

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v2.20.8
1+
v2.20.9

0 commit comments

Comments
 (0)