Skip to content

feat: change v4 payload topic to v3 format, add topicBytes field#102

Merged
neekolas merged 3 commits into
xmtp:mainfrom
xmtp-coder-agent:fix/issue-101
Apr 9, 2026
Merged

feat: change v4 payload topic to v3 format, add topicBytes field#102
neekolas merged 3 commits into
xmtp:mainfrom
xmtp-coder-agent:fix/issue-101

Conversation

@xmtp-coder-agent

@xmtp-coder-agent xmtp-coder-agent commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator

Resolves #101

Summary

  • buildV4SendRequest now sets Topic to V3 string format (TopicToLegacy) instead of V4 base64 (TopicToBase64)
  • New TopicBytes field on SendRequest carries the V4 binary topic as base64
  • APNS: includes topicBytesB64 custom field when present
  • FCM: includes topicBytesB64 in data map and APNS custom data when present
  • HTTP: topicBytesB64 included in JSON via MarshalJSON (omitted when empty)
  • All existing V3 delivery paths unchanged — topicBytesB64 only appears for V4 payloads

Files Changed

File Change
pkg/interfaces/interfaces.go Add TopicBytes to SendRequest, topicBytesB64 to JSON marshaling
pkg/xmtp/v4_listener.go buildV4SendRequest uses TopicToLegacy for Topic, TopicToBase64 for TopicBytes
pkg/delivery/apns.go Conditionally add topicBytesB64 to APNS notification payload
pkg/delivery/fcm.go Conditionally add topicBytesB64 to FCM data and APNS custom data

Test plan

  • pkg/interfaces — new tests for TopicBytes JSON marshaling (included + omitted when empty)
  • pkg/delivery — new V4 tests for APNS and FCM topicBytesB64 field
  • pkg/xmtp — updated V4 listener tests assert V3 topic format + TopicBytes field
  • go build ./... — compiles cleanly
  • go vet ./... — no issues
  • Non-DB tests pass (pkg/interfaces, pkg/delivery, pkg/topics)
  • DB-dependent tests (pkg/xmtp, pkg/db) require PostgreSQL — verified logic changes only

🤖 Generated with Claude Code

Note

Add topicBytesB64 field to V4 push notification payloads and set V4 topic to legacy format

  • V4 SendRequest now carries both a legacy string Topic and a new TopicBytesB64 field containing the base64-encoded topic bytes, set in v4_listener.go.
  • topicBytesB64 is conditionally included in APNS custom payloads and FCM Data/APNS.CustomData when the field is non-empty.
  • SendRequest.MarshalJSON emits topicBytesB64 in the JSON wire format when set, via the interfaces.go custom marshaler.
  • Behavioral Change: V4 Topic is now set to the legacy string representation instead of raw topic bytes, which affects downstream consumers reading the Topic field.

Macroscope summarized 5507525.

The topic field in V4 delivery notification payloads now uses the V3
string format (e.g., /xmtp/mls/1/g-<hex>/proto). A new topicBytes
field (topicBytesB64 in JSON/APNS/FCM) carries the V4 binary topic
as base64. This applies to all delivery channels: APNS, FCM, and HTTP.

Resolves xmtp#101

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread pkg/interfaces/interfaces.go Outdated
Rename the Go struct field from TopicBytes to TopicBytesB64 to match
the JSON field name everywhere and avoid confusion.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@neekolas neekolas marked this pull request as ready for review April 9, 2026 20:18
@neekolas neekolas requested a review from a team as a code owner April 9, 2026 20:18
The previous CI run failed with "xnet-node did not become ready for
message-source v3-direct" — a transient container readiness timeout
unrelated to code changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@neekolas neekolas merged commit e5ee784 into xmtp:main Apr 9, 2026
5 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.

Change topic format for v4 payloads

2 participants