Refactor chat system to remove E2EE and simplify messaging

Removed all E2EE chat endpoints, crypto logic, and related API routes, transitioning chat to plain text storage and transport. Updated chat send/receive endpoints to use signed actions and enforce DM privacy settings. Cleaned up Swarm chat inbox, key management, and related debug endpoints. Updated user profile to support DM privacy, improved search for handle queries, and refactored conversation/message logic to support the new model. Migrated bot settings and privacy settings to new locations.
This commit is contained in:
Christopher
2026-01-28 13:05:34 -08:00
parent b52b3f9804
commit ceae76d58f
44 changed files with 1945 additions and 3058 deletions
+32 -5
View File
@@ -1,6 +1,7 @@
import { NextResponse } from 'next/server';
import { db, users } from '@/db';
import { eq } from 'drizzle-orm';
import { eq, and } from 'drizzle-orm';
import { getSession } from '@/lib/auth';
import { db, users, follows } from '@/db';
import { fetchSwarmUserProfile, isSwarmNode } from '@/lib/swarm/interactions';
type RouteContext = { params: Promise<{ handle: string }> };
@@ -62,7 +63,6 @@ export async function GET(request: Request, context: RouteContext) {
isSwarm: true,
nodeDomain: remoteDomain,
isBot: profile.isBot || false,
chatPublicKey: profile.chatPublicKey,
did: profile.did,
}
});
@@ -96,11 +96,38 @@ export async function GET(request: Request, context: RouteContext) {
website: user.website,
movedTo: user.movedTo,
isBot: user.isBot,
publicKey: user.publicKey, // RSA key for signing
chatPublicKey: user.chatPublicKey, // ECDH key for E2E chat
publicKey: user.publicKey, // Signing key
did: user.did, // V2 Identity
dmPrivacy: user.dmPrivacy,
};
// Check if viewer can DM this user
let canReceiveDms = true;
if (user.isBot) {
canReceiveDms = false;
} else if (user.dmPrivacy === 'none') {
canReceiveDms = false;
} else if (user.dmPrivacy === 'following') {
canReceiveDms = false; // Default to false for 'following'
const session = await getSession();
if (session?.user) {
if (session.user.id === user.id) {
canReceiveDms = true; // Can DM yourself
} else {
const isFollowingViewer = await db.query.follows.findFirst({
where: and(
eq(follows.followerId, user.id),
eq(follows.followingId, session.user.id)
)
});
if (isFollowingViewer) {
canReceiveDms = true;
}
}
}
}
userResponse.canReceiveDms = canReceiveDms;
// If this is a bot, include owner info
if (user.isBot && user.botOwnerId) {
const owner = await db.query.users.findFirst({