Add sender_did to chat messages and new chat tables
Introduces a migration to add a sender_did column to the chat_messages table and creates new tables for chat_device_bundles, chat_inbox, and chat_one_time_keys. Updates related API routes and adds a script for sender DID migration. These changes support device-based messaging and improved chat security.
This commit is contained in:
@@ -128,13 +128,20 @@ export async function POST(request: NextRequest) {
|
||||
const localDomain = process.env.NEXT_PUBLIC_NODE_DOMAIN || 'localhost';
|
||||
const swarmMessageId = `swarm:${localDomain}:${messageId}`;
|
||||
|
||||
// Store full envelope data for decryption
|
||||
const envelopeData = {
|
||||
did: user.did,
|
||||
handle: user.handle,
|
||||
ciphertext: ciphertext
|
||||
};
|
||||
|
||||
const [newMessage] = await db.insert(chatMessages).values({
|
||||
conversationId: conversation.id,
|
||||
senderHandle: user.handle,
|
||||
senderDisplayName: user.displayName,
|
||||
senderAvatarUrl: user.avatarUrl,
|
||||
senderNodeDomain: null, // Local sender
|
||||
encryptedContent: ciphertext,
|
||||
encryptedContent: JSON.stringify(envelopeData), // Full envelope
|
||||
senderChatPublicKey: null, // V2 E2E - keys are in the envelope
|
||||
swarmMessageId,
|
||||
deliveredAt: null, // Will update when remote confirms
|
||||
|
||||
Reference in New Issue
Block a user