Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ class ContentJson(
)

ContentTypeGroupUpdated.id -> mapOf(
"initiatedByInboxId" to (content as GroupUpdated).initiatedByInboxId,
"groupUpdated" to mapOf(
"initiatedByInboxId" to (content as GroupUpdated).initiatedByInboxId,
"membersAdded" to content.addedInboxesList.map {
mapOf(
"inboxId" to it.inboxId
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,7 @@ PODS:
- CSecp256k1 (~> 0.2)
- LibXMTP (= 4.4.0)
- SQLCipher (= 4.5.7)
- XMTPReactNative (4.4.0-rc2):
- XMTPReactNative (4.4.0):
- CSecp256k1 (~> 0.2)
- ExpoModulesCore
- MessagePacker
Expand Down Expand Up @@ -2161,7 +2161,7 @@ SPEC CHECKSUMS:
SQLCipher: 5e6bfb47323635c8b657b1b27d25c5f1baf63bf5
SwiftProtobuf: 4dbaffec76a39a8dc5da23b40af1a5dc01a4c02d
XMTP: 720c5d4726f869ea38668735da9777ecc851fd89
XMTPReactNative: 2c11827d2b901f9865376bb1033b14b7eb3acbfb
XMTPReactNative: c2b932b71ff9dccebe37e2c8edde38720e8cc270
Yoga: feb4910aba9742cfedc059e2b2902e22ffe9954a

PODFILE CHECKSUM: 283c313cbc1ba9857a692b5901eb740dad922eca
Expand Down
56 changes: 56 additions & 0 deletions example/src/tests/conversationTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
Conversation,
ConversationId,
ConversationVersion,
GroupUpdatedCodec,
GroupUpdatedContent,
JSContentCodec,
} from '../../../src/index'

Expand Down Expand Up @@ -1328,3 +1330,57 @@ test('messages dont disappear newGroupWithIdentities', async () => {

return true
})

test('new groups and dms contain a message including who added the user', async () => {
const [alix, bo] = await createClients(2)

// Register the GroupUpdatedCodec to handle group updated messages
Client.register(new GroupUpdatedCodec())

// Test that group we are added to contains the GroupUpdated message with who added us
const alixGroup = await alix.conversations.newGroup([bo.inboxId])
await bo.conversations.sync()
const boGroup = await bo.conversations.findGroup(alixGroup.id)
const boGroupMessages = await boGroup?.messages()
assert(boGroupMessages!.length === 1, 'Bo group should have 1 message')

const message = boGroupMessages![0]
await assertEqual(
message.contentTypeId,
'xmtp.org/group_updated:1.0',
'Message should be a group updated message'
)
console.log(message.contentTypeId)

const groupUpdatedMessage: GroupUpdatedContent = message.content()
const addedByInboxId = groupUpdatedMessage.initiatedByInboxId
await assertEqual(
addedByInboxId,
alix.inboxId,
'Added by inbox id should be alix'
)

// Test that dm we are added to contains the GroupUpdated message with who added us
const boDm = await bo.conversations.findOrCreateDm(alix.inboxId)
await bo.conversations.sync()
const alixDm = await bo.conversations.findConversation(boDm.id)
const alixDmMessages = await alixDm?.messages()
assert(alixDmMessages!.length === 1, 'Bo dm should have 1 message')
const dmMessage = alixDmMessages![0]
await assertEqual(
dmMessage.contentTypeId,
'xmtp.org/group_updated:1.0',
'Message should be a group updated message'
)
console.log(dmMessage.contentTypeId)

const dmGroupUpdatedMessage: GroupUpdatedContent = dmMessage.content()
const dmAddedByInboxId = dmGroupUpdatedMessage.initiatedByInboxId
await assertEqual(
dmAddedByInboxId,
bo.inboxId,
'Added by inbox id should be bo'
)

return true
})
Loading