Check for own transfers on every app open, not only with a bank sync
The bank sync runs at most every 6 hours (and never without a linked bank), so transfers in imported statements stayed counted as spending and income. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
759b0c0d62
commit
730d99d38b
2 files changed
+21
-3
No files matched your search
@@ -0,0 +1,16 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { fileOwnTransfers } from "@/lib/sync";
|
||||
import { createClient } from "@/utils/supabase/server";
|
||||
|
||||
// Marks transfers between the signed-in user's own accounts (lib/transfers.ts findOwnTransfers). AutoSync calls it on
|
||||
// opening broke, apart from the bank sync, which only runs every few hours: imported statements need it too.
|
||||
export async function POST() {
|
||||
const { data: { user } } = await (await createClient()).auth.getUser();
|
||||
if (!user) return NextResponse.json({ error: "Not signed in" }, { status: 401 });
|
||||
try {
|
||||
return NextResponse.json({ marked: await fileOwnTransfers(user.id) });
|
||||
} catch (e) {
|
||||
console.error("[broke] own transfers:", e instanceof Error ? e.message : e);
|
||||
return NextResponse.json({ error: "Couldn't check for transfers." }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user