Skip to content

Dedicated payload column for system messages #334

Description

@codebestia

messages.ciphertext is the only content column on the messages table. System messages (device add/revoke, membership changes) are produced by JSON.stringify({userId, change}) and written directly into that same field (emitDeviceChangeEvent in routes/devices.ts). This conflates genuine E2EE ciphertext (opaque, per-device-encrypted) with structured unencrypted metadata in one column.

Acceptance criteria:

  • A new dedicated jsonb column (systemPayload) is added to messages for content_type = 'system' rows, with a migration
  • emitDeviceChangeEvent and any other system-message producer write to the new column, leaving ciphertext null for system messages
  • Read paths read systemPayload for system messages instead of JSON-parsing ciphertext
  • A check constraint ensures content_type = 'system' rows have ciphertext IS NULL and non-null systemPayload

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions