Skip to content

Commit

Permalink
fix: ios string ids instead of data
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Jul 9, 2024
1 parent a70b573 commit a948020
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion example/src/tests/groupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ test('unpublished messages handling', async () => {
}

// Publish the prepared message
await alixGroup.publishPreparedMessage(preparedMessageId)
await alixGroup.publishPreparedMessages()

// Sync the group after publishing the message
await alixGroup.sync()
Expand Down
2 changes: 1 addition & 1 deletion ios/Wrappers/GroupWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct GroupWrapper {
static func encodeToObj(_ group: XMTP.Group, client: XMTP.Client) throws -> [String: Any] {
return [
"clientAddress": client.address,
"id": group.id.toHex,
"id": group.id,
"createdAt": UInt64(group.createdAt.timeIntervalSince1970 * 1000),
"peerInboxIds": try group.peerInboxIds,
"version": "GROUP",
Expand Down
12 changes: 5 additions & 7 deletions ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ public class XMTPModule: Module {
guard let client = await clientsManager.getClient(key: inboxId) else {
throw Error.noClient
}
if let message = try client.findMessage(messageId: Data(hex: messageId) ?? Data()) {
if let message = try client.findMessage(messageId: messageId) {
return try DecodedMessageWrapper.encode(message.decrypt(), client: client)
} else {
return nil
Expand All @@ -503,7 +503,7 @@ public class XMTPModule: Module {
guard let client = await clientsManager.getClient(key: inboxId) else {
throw Error.noClient
}
if let group = try client.findGroup(groupId: Data(hex: groupId) ?? Data()) {
if let group = try client.findGroup(groupId: groupId) {
return try GroupWrapper.encode(group, client: client)
} else {
return nil
Expand Down Expand Up @@ -1368,16 +1368,14 @@ public class XMTPModule: Module {
guard let client = await clientsManager.getClient(key: inboxId) else {
throw Error.noClient
}
let groupDataIds = groupIds.compactMap { $0.hexToData }
try await client.contacts.allowGroups(groupIds: groupDataIds)
try await client.contacts.allowGroups(groupIds: groupIds)
}

AsyncFunction("denyGroups") { (inboxId: String, groupIds: [String]) in
guard let client = await clientsManager.getClient(key: inboxId) else {
throw Error.noClient
}
let groupDataIds = groupIds.compactMap { $0.hexToData }
try await client.contacts.denyGroups(groupIds: groupDataIds)
try await client.contacts.denyGroups(groupIds: groupIds)
}

AsyncFunction("isGroupAllowed") { (inboxId: String, groupId: String) -> Bool in
Expand Down Expand Up @@ -1468,7 +1466,7 @@ public class XMTPModule: Module {
let cacheKey = XMTP.Group.cacheKeyForId(inboxId: client.inboxID, id: id)
if let group = await groupsManager.get(cacheKey) {
return group
} else if let group = try await client.conversations.groups().first(where: { $0.id.toHex == id }) {
} else if let group = try client.findGroup(groupId: id) {
await groupsManager.set(cacheKey, group)
return group
}
Expand Down

0 comments on commit a948020

Please sign in to comment.