fix: use inTx wrapper instead of raw transactions for friend operations

Fixes "undefined reading push" error by using the inTx wrapper which properly
initializes the callbacks array needed by afterTx for notification sending.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
Steve Korshakov 2025-09-20 17:00:05 -07:00
parent c534331ce5
commit 9822512aeb
2 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,6 @@
import { Context } from "@/context";
import { buildUserProfile, UserProfile } from "./type";
import { db } from "@/storage/db";
import { inTx } from "@/storage/inTx";
import { RelationshipStatus } from "@prisma/client";
import { relationshipSet } from "./relationshipSet";
import { relationshipGet } from "./relationshipGet";
@ -20,7 +20,7 @@ export async function friendAdd(ctx: Context, uid: string): Promise<UserProfile
}
// Update relationship status
return await db.$transaction(async (tx) => {
return await inTx(async (tx) => {
// Read current user objects
const currentUser = await tx.account.findUnique({

View File

@ -1,12 +1,12 @@
import { Context } from "@/context";
import { buildUserProfile, UserProfile } from "./type";
import { db } from "@/storage/db";
import { inTx } from "@/storage/inTx";
import { RelationshipStatus } from "@prisma/client";
import { relationshipSet } from "./relationshipSet";
import { relationshipGet } from "./relationshipGet";
export async function friendRemove(ctx: Context, uid: string): Promise<UserProfile | null> {
return await db.$transaction(async (tx) => {
return await inTx(async (tx) => {
// Read current user objects
const currentUser = await tx.account.findUnique({