Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions apps/server/src/thread-workflow-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { composeEmail } from '../trpc/routes/ai/compose';
import { type ParsedMessage } from '../types';
import { connection } from '../db/schema';

const dontReplyTo = new Set([
'no-reply@gmail.com',
'noreply@gmail.com',
'do-not-reply@gmail.com',
'do-not-reply@gmail.com',
'notifications@github.com',
'info@e-mail.xing.com',
]);

const shouldGenerateDraft = async (
thread: IGetThreadResponse,
foundConnection: typeof connection.$inferSelect,
Expand Down Expand Up @@ -38,6 +47,11 @@ const shouldGenerateDraft = async (
return false;
}

if (dontReplyTo.has(senderEmail)) {
console.log('[SHOULD_GENERATE_DRAFT] Message is from a dont reply to email, skipping draft');
return false;
}

if (latestMessage.receivedOn) {
const messageDate = new Date(latestMessage.receivedOn);
const sevenDaysAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
Expand Down