-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Move to folder action #668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e35609f
6d539c3
af8992f
2c93da7
bfe6890
2da5a75
f5d775e
8e1aa36
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| -- AlterEnum | ||
| ALTER TYPE "ActionType" ADD VALUE 'MOVE_FOLDER'; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "Action" ADD COLUMN "folderName" TEXT; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "ExecutedAction" ADD COLUMN "folderName" TEXT; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "ScheduledAction" ADD COLUMN "folderName" TEXT; | ||
|
Comment on lines
+5
to
+11
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enforce data integrity for MOVE_FOLDER actions folderName is nullable, which is correct for non-MOVE_FOLDER actions. To prevent invalid rows, add CHECK constraints requiring folderName when type='MOVE_FOLDER' (and optionally disallowing it otherwise). This catches issues at the DB boundary and simplifies downstream assumptions. Proposed follow-up migration (apply at the DB level): ALTER TABLE "Action"
ADD CONSTRAINT action_move_folder_requires_name
CHECK (("type" <> 'MOVE_FOLDER') OR ("folderName" IS NOT NULL AND length(trim("folderName")) > 0));
ALTER TABLE "ExecutedAction"
ADD CONSTRAINT executed_action_move_folder_requires_name
CHECK (("type" <> 'MOVE_FOLDER') OR ("folderName" IS NOT NULL AND length(trim("folderName")) > 0));
ALTER TABLE "ScheduledAction"
ADD CONSTRAINT scheduled_action_move_folder_requires_name
CHECK (("type" <> 'MOVE_FOLDER') OR ("folderName" IS NOT NULL AND length(trim("folderName")) > 0));Optional: If Outlook mapping relies on stable IDs, consider storing provider folder IDs instead of names (or alongside names) to survive renames and localization. 🤖 Prompt for AI Agents |
||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "VerificationToken" ALTER COLUMN "id" DROP DEFAULT; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixing the default generated from the better-auth migration |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,6 @@ import { enableReplyTracker } from "@/utils/reply-tracker/enable"; | |
| import { actionClient } from "@/utils/actions/safe-action"; | ||
| import { getGmailClientForEmail } from "@/utils/account"; | ||
| import { SafeError } from "@/utils/error"; | ||
| import { getEmailAccountWithAi } from "@/utils/user/get"; | ||
| import { prefixPath } from "@/utils/path"; | ||
|
|
||
| const logger = createScopedLogger("enableReplyTracker"); | ||
|
|
@@ -31,7 +30,22 @@ export const enableReplyTrackerAction = actionClient | |
| export const processPreviousSentEmailsAction = actionClient | ||
| .metadata({ name: "processPreviousSentEmails" }) | ||
| .action(async ({ ctx: { emailAccountId } }) => { | ||
| const emailAccount = await getEmailAccountWithAi({ emailAccountId }); | ||
| const emailAccount = await prisma.emailAccount.findUnique({ | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reply tracking is only implemented for Gmail, so I changed the query here to also fetch the provider and skip it if is not Gmail. |
||
| where: { id: emailAccountId }, | ||
| select: { | ||
| account: { select: { provider: true } }, | ||
| user: { select: { aiProvider: true, aiModel: true, aiApiKey: true } }, | ||
| id: true, | ||
| email: true, | ||
| userId: true, | ||
| about: true, | ||
| }, | ||
| }); | ||
|
|
||
| if (emailAccount?.account?.provider !== "google") { | ||
| return { success: true }; | ||
| } | ||
|
Comment on lines
+45
to
+47
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Provider gate swallows “account not found” — reorder checks As written, a missing account (emailAccount === null) will hit the early “not google” return and silently succeed, bypassing the intended SafeError. Reorder the null check before the provider gate. Apply: - if (emailAccount?.account?.provider !== "google") {
- return { success: true };
- }
-
- if (!emailAccount) throw new SafeError("Email account not found");
+ if (!emailAccount) {
+ throw new SafeError("Email account not found");
+ }
+ if (emailAccount.account?.provider !== "google") {
+ return { success: true };
+ }Also applies to: 49-49 🤖 Prompt for AI Agents |
||
|
|
||
| if (!emailAccount) throw new SafeError("Email account not found"); | ||
|
|
||
| const gmail = await getGmailClientForEmail({ emailAccountId }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Analyze sender pattern is not implemented for Outlook