Skip to content

feat: migrate messages content to ciphertext (#173)#249

Merged
codebestia merged 7 commits into
codebestia:mainfrom
Gabugo-tech:feature/173-migrate-messages-ciphertext
Jun 29, 2026
Merged

feat: migrate messages content to ciphertext (#173)#249
codebestia merged 7 commits into
codebestia:mainfrom
Gabugo-tech:feature/173-migrate-messages-ciphertext

Conversation

@Gabugo-tech

Copy link
Copy Markdown

Description

This PR migrates the messages table and its dependent codebase to use E2E encrypted ciphertext payloads instead of plain text content. This prepares the backend for group/MLS single-ciphertext messages where the server can no longer read the contents of messages directly.

Changes Made:

  • Database Schema (apps/backend/src/db/schema.ts):
    • Dropped the content column in the messages table.
    • Added a nullable ciphertext column.
    • Removed the messages_content_search_idx Gin index that was built for full-text search on plain text content.
  • Message Serialization (apps/backend/src/lib/messages.ts):
    • Updated serializeMessage to accept and correctly handle ciphertext.
  • API & Routes (apps/backend/src/routes/conversations.ts):
    • Removed the GET /:id/search full-text search endpoint since the backend can no longer query plain text message content.
  • Websockets Integration (apps/backend/src/socket/messaging.ts):
    • Replaced content payloads with ciphertext in send_message and ask_assistant event handlers.
  • Testing:
    • Migrated all mock values and testing payloads to use ciphertext instead of content.
    • Deleted full-text search endpoint unit tests.

Related Issues

Acceptance Criteria

  • content column dropped; ciphertext added (nullable)
  • serializeMessage no longer references plaintext
  • Message insert paths and sockets updated
  • Search removal coordinated
  • Application successfully compiles and all tests pass

closes #173

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@Gabugo-tech Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@codebestia

Copy link
Copy Markdown
Owner

@Gabugo-tech
Please fix the CI

@codebestia

Copy link
Copy Markdown
Owner

@Gabugo-tech
Please fix the CI and resolve the conflicts.
Thanks

AI Bot added 4 commits June 29, 2026 19:54
Search is disabled in E2EE environments since the server can no longer
read ciphertext. Route returns 501, test updated to match.
- Drop messages_content_search_idx (GIN index on plaintext content)
- Add nullable ciphertext column to messages table
- Migrate existing content values into ciphertext
- Drop plaintext content column
- schema.ts: keep upstream's extended messages table (senderDeviceId,
  contentType, sequenceNumber, editsMessageId) + messageEnvelopes table
- messages.ts: use upstream's serializeMessage with envelope priority
  and unavailable flag
- conversations.ts: use upstream's getConversationRelations(deviceId)
  and 501 search stub
- messaging.ts: use upstream's full send_message/edit_message/typing
  handlers; fix ask_assistant to pass ciphertext not content
Comment thread commit_msg.txt Outdated

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this file.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on it, stand by please

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, i will love if ypu can assign me another issue, i promise to submit pr within some minutes

@codebestia codebestia left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Thank you for your contribution.

@codebestia codebestia merged commit 7645269 into codebestia:main Jun 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add messages.ciphertext for single-blob messages + remove plaintext content

2 participants