Skip to content

Commit 34d4d81

Browse files
authored
Adds test and fix initiatedBy parsing on android (#712)
Co-authored-by: cameronvoell <[email protected]>
1 parent fdeee27 commit 34d4d81

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/ContentJson.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ class ContentJson(
260260
)
261261

262262
ContentTypeGroupUpdated.id -> mapOf(
263-
"initiatedByInboxId" to (content as GroupUpdated).initiatedByInboxId,
264263
"groupUpdated" to mapOf(
264+
"initiatedByInboxId" to (content as GroupUpdated).initiatedByInboxId,
265265
"membersAdded" to content.addedInboxesList.map {
266266
mapOf(
267267
"inboxId" to it.inboxId

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,7 +1743,7 @@ PODS:
17431743
- CSecp256k1 (~> 0.2)
17441744
- LibXMTP (= 4.4.0)
17451745
- SQLCipher (= 4.5.7)
1746-
- XMTPReactNative (4.4.0-rc2):
1746+
- XMTPReactNative (4.4.0):
17471747
- CSecp256k1 (~> 0.2)
17481748
- ExpoModulesCore
17491749
- MessagePacker
@@ -2161,7 +2161,7 @@ SPEC CHECKSUMS:
21612161
SQLCipher: 5e6bfb47323635c8b657b1b27d25c5f1baf63bf5
21622162
SwiftProtobuf: 4dbaffec76a39a8dc5da23b40af1a5dc01a4c02d
21632163
XMTP: 720c5d4726f869ea38668735da9777ecc851fd89
2164-
XMTPReactNative: 2c11827d2b901f9865376bb1033b14b7eb3acbfb
2164+
XMTPReactNative: c2b932b71ff9dccebe37e2c8edde38720e8cc270
21652165
Yoga: feb4910aba9742cfedc059e2b2902e22ffe9954a
21662166

21672167
PODFILE CHECKSUM: 283c313cbc1ba9857a692b5901eb740dad922eca

example/src/tests/conversationTests.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import {
1616
Conversation,
1717
ConversationId,
1818
ConversationVersion,
19+
GroupUpdatedCodec,
20+
GroupUpdatedContent,
1921
JSContentCodec,
2022
} from '../../../src/index'
2123

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

13291331
return true
13301332
})
1333+
1334+
test('new groups and dms contain a message including who added the user', async () => {
1335+
const [alix, bo] = await createClients(2)
1336+
1337+
// Register the GroupUpdatedCodec to handle group updated messages
1338+
Client.register(new GroupUpdatedCodec())
1339+
1340+
// Test that group we are added to contains the GroupUpdated message with who added us
1341+
const alixGroup = await alix.conversations.newGroup([bo.inboxId])
1342+
await bo.conversations.sync()
1343+
const boGroup = await bo.conversations.findGroup(alixGroup.id)
1344+
const boGroupMessages = await boGroup?.messages()
1345+
assert(boGroupMessages!.length === 1, 'Bo group should have 1 message')
1346+
1347+
const message = boGroupMessages![0]
1348+
await assertEqual(
1349+
message.contentTypeId,
1350+
'xmtp.org/group_updated:1.0',
1351+
'Message should be a group updated message'
1352+
)
1353+
console.log(message.contentTypeId)
1354+
1355+
const groupUpdatedMessage: GroupUpdatedContent = message.content()
1356+
const addedByInboxId = groupUpdatedMessage.initiatedByInboxId
1357+
await assertEqual(
1358+
addedByInboxId,
1359+
alix.inboxId,
1360+
'Added by inbox id should be alix'
1361+
)
1362+
1363+
// Test that dm we are added to contains the GroupUpdated message with who added us
1364+
const boDm = await bo.conversations.findOrCreateDm(alix.inboxId)
1365+
await bo.conversations.sync()
1366+
const alixDm = await bo.conversations.findConversation(boDm.id)
1367+
const alixDmMessages = await alixDm?.messages()
1368+
assert(alixDmMessages!.length === 1, 'Bo dm should have 1 message')
1369+
const dmMessage = alixDmMessages![0]
1370+
await assertEqual(
1371+
dmMessage.contentTypeId,
1372+
'xmtp.org/group_updated:1.0',
1373+
'Message should be a group updated message'
1374+
)
1375+
console.log(dmMessage.contentTypeId)
1376+
1377+
const dmGroupUpdatedMessage: GroupUpdatedContent = dmMessage.content()
1378+
const dmAddedByInboxId = dmGroupUpdatedMessage.initiatedByInboxId
1379+
await assertEqual(
1380+
dmAddedByInboxId,
1381+
bo.inboxId,
1382+
'Added by inbox id should be bo'
1383+
)
1384+
1385+
return true
1386+
})

0 commit comments

Comments
 (0)