feat: remove avatar on GitHub disconnect
Update GitHub disconnect endpoint to also remove user avatar: - Clear avatar field in database (set to Prisma.JsonNull) - Include avatar removal in account update broadcast - Update logging to reflect avatar removal 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
5269de150a
commit
42f2f30b6a
@ -5,7 +5,7 @@ import { Server, Socket } from "socket.io";
|
||||
import { z } from "zod";
|
||||
import * as privacyKit from "privacy-kit";
|
||||
import { db } from "@/storage/db";
|
||||
import { Account } from "@prisma/client";
|
||||
import { Account, Prisma } from "@prisma/client";
|
||||
import { onShutdown } from "@/utils/shutdown";
|
||||
import { allocateSessionSeq, allocateUserSeq } from "@/services/seq";
|
||||
import { randomKeyNaked } from "@/utils/randomKeyNaked";
|
||||
@ -633,10 +633,13 @@ export async function startApi(): Promise<{ app: FastifyInstance; io: Server }>
|
||||
|
||||
// Remove GitHub connection from account and delete GitHub user record
|
||||
await db.$transaction(async (tx) => {
|
||||
// Remove link from account
|
||||
// Remove link from account and clear avatar
|
||||
await tx.account.update({
|
||||
where: { id: userId },
|
||||
data: { githubUserId: null }
|
||||
data: {
|
||||
githubUserId: null,
|
||||
avatar: Prisma.JsonNull
|
||||
}
|
||||
});
|
||||
|
||||
// Delete GitHub user record (this also deletes the token)
|
||||
@ -648,7 +651,8 @@ export async function startApi(): Promise<{ app: FastifyInstance; io: Server }>
|
||||
// Send account update to all user connections
|
||||
const updSeq = await allocateUserSeq(userId);
|
||||
const updatePayload = buildUpdateAccountUpdate(userId, {
|
||||
github: null
|
||||
github: null,
|
||||
avatar: null
|
||||
}, updSeq, randomKeyNaked(12));
|
||||
eventRouter.emitUpdate({
|
||||
userId,
|
||||
@ -656,7 +660,7 @@ export async function startApi(): Promise<{ app: FastifyInstance; io: Server }>
|
||||
recipientFilter: { type: 'all-user-authenticated-connections' }
|
||||
});
|
||||
|
||||
log({ module: 'github-disconnect' }, `GitHub account disconnected successfully for user ${userId}`);
|
||||
log({ module: 'github-disconnect' }, `GitHub account and avatar disconnected successfully for user ${userId}`);
|
||||
|
||||
return reply.send({ success: true });
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user