feat(chat): Validate and cache remote user public keys for encryption

- Add validation to check if cached users have valid public keys (PEM format)
- Fetch remote public keys when local cache has placeholder/invalid keys
- Update existing cached users with real public keys instead of creating duplicates
- Include public key in user profile API response for E2E encrypted chat support
- Improve error handling to reject recipients without valid encryption keys
- Ensure remote user data is properly extracted from API responses
This prevents sending encrypted messages to users with placeholder keys and ensures the chat system always has access to valid public keys for encryption operations.
This commit is contained in:
Christomatt
2026-01-27 02:12:43 +01:00
parent 998a1bcf4a
commit fb2c80b0e3
2 changed files with 32 additions and 14 deletions
+1
View File
@@ -94,6 +94,7 @@ export async function GET(request: Request, context: RouteContext) {
website: user.website,
movedTo: user.movedTo,
isBot: user.isBot,
publicKey: user.publicKey, // Needed for E2E encrypted chat
};
// If this is a bot, include owner info