Skip to content

Commit

Permalink
Update consent syncing and removes group update message from dms (#429)
Browse files Browse the repository at this point in the history
* update package

* get all the tests passing ont he latest
  • Loading branch information
nplasterer authored Nov 15, 2024
1 parent cb6bb37 commit 95f7910
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let package = Package(
.package(url: "https://github.com/1024jp/GzipSwift", from: "5.2.0"),
.package(url: "https://github.com/bufbuild/connect-swift", exact: "0.12.0"),
.package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.0.0"),
.package(url: "https://github.com/xmtp/libxmtp-swift.git", exact: "3.0.0"),
.package(url: "https://github.com/xmtp/libxmtp-swift.git", exact: "3.0.1"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
17 changes: 10 additions & 7 deletions Sources/XMTPiOS/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public struct ClientOptions {
self.historySyncUrl =
"https://message-history.production.ephemera.network/"
case .local:
self.historySyncUrl = "http://0.0.0.0:5558"
self.historySyncUrl = "http://localhost:5558"
default:
self.historySyncUrl =
"https://message-history.dev.ephemera.network/"
Expand Down Expand Up @@ -112,14 +112,14 @@ public final class Client {
inboxId: String
) async throws -> Client {
let (libxmtpClient, dbPath) = try await initFFiClient(
accountAddress: accountAddress,
accountAddress: accountAddress.lowercased(),
options: options,
signingKey: signingKey,
inboxId: inboxId
)

let client = try Client(
address: accountAddress,
address: accountAddress.lowercased(),
ffiClient: libxmtpClient,
dbPath: dbPath,
installationID: libxmtpClient.installationId().toHex,
Expand Down Expand Up @@ -224,7 +224,7 @@ public final class Client {
message: signatureRequest.signatureText())
try await signatureRequest.addScwSignature(
signatureBytes: signedData,
address: signingKey.address,
address: signingKey.address.lowercased(),
chainId: UInt64(chainId),
blockNumber: signingKey.blockNumber.flatMap {
$0 >= 0 ? UInt64($0) : nil
Expand Down Expand Up @@ -265,10 +265,13 @@ public final class Client {
logger: XMTPLogger(),
host: api.env.url,
isSecure: api.env.isSecure == true,
accountAddress: address
) ?? generateInboxId(accountAddress: address, nonce: 0)
accountAddress: address.lowercased()
)
?? generateInboxId(
accountAddress: address.lowercased(), nonce: 0)
} catch {
inboxId = try generateInboxId(accountAddress: address, nonce: 0)
inboxId = try generateInboxId(
accountAddress: address.lowercased(), nonce: 0)
}
return inboxId
}
Expand Down
7 changes: 3 additions & 4 deletions Sources/XMTPiOS/Conversations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,13 @@ public actor Conversations {
return
}
do {
let conversationType = try conversation.groupMetadata()
.conversationType()
if conversationType == "dm" {
let conversationType = try conversation.conversationType()
if conversationType == .dm {
continuation.yield(
Conversation.dm(
conversation.dmFromFFI(client: self.client))
)
} else if conversationType == "group" {
} else if conversationType == .group {
continuation.yield(
Conversation.group(
conversation.groupFromFFI(client: self.client))
Expand Down
2 changes: 1 addition & 1 deletion Sources/XMTPiOS/Extensions/Ffi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extension FfiConversation {
}

func toConversation(client: Client) throws -> Conversation {
if try groupMetadata().conversationType() == "dm" {
if try conversationType() == .dm {
return Conversation.dm(self.dmFromFFI(client: client))
} else {
return Conversation.group(self.groupFromFFI(client: client))
Expand Down
2 changes: 1 addition & 1 deletion Tests/XMTPTests/AttachmentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AttachmentsTests: XCTestCase {
options: .init(contentType: ContentTypeAttachment))
let messages = try await conversation.messages()

XCTAssertEqual(2, messages.count)
XCTAssertEqual(1, messages.count)

let message = messages[0]
let attachment: Attachment = try message.content()
Expand Down
4 changes: 2 additions & 2 deletions Tests/XMTPTests/CodecTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CodecTests: XCTestCase {
options: .init(contentType: NumberCodec().contentType))

let messages = try await alixConversation.messages()
XCTAssertEqual(messages.count, 2)
XCTAssertEqual(messages.count, 1)

if messages.count == 1 {
let content: Double = try messages[0].content()
Expand All @@ -80,7 +80,7 @@ class CodecTests: XCTestCase {
alixClient.codecRegistry.codecs.removeValue(forKey: NumberCodec().id)

let messages = try await alixConversation.messages()
XCTAssertEqual(messages.count, 2)
XCTAssertEqual(messages.count, 1)

let content: Double? = try? messages[0].content()
XCTAssertEqual(nil, content)
Expand Down
7 changes: 6 additions & 1 deletion Tests/XMTPTests/ConversationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,15 @@ class ConversationTests: XCTestCase {

try await fixtures.boClient.conversations.sync()
try await boDm?.sync()
try await alixClient.conversations.sync()
try await alixClient2.conversations.sync()
try await alixClient2.syncConsent()
try await alixClient.conversations.syncAllConversations()
sleep(2)
try await alixClient2.conversations.syncAllConversations()
sleep(2)

if let dm2 = try alixClient2.findConversation(conversationId: dm.id) {
try await alixClient2.syncConsent()
XCTAssertEqual(try dm2.consentState(), .denied)

try await alixClient2.preferences.consentList.setConsentState(
Expand Down
2 changes: 1 addition & 1 deletion Tests/XMTPTests/DmTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class DmTests: XCTestCase {
XCTAssertEqual(firstMessage.id, messageId)
XCTAssertEqual(firstMessage.deliveryStatus, .published)
let messages = try await dm.messages()
XCTAssertEqual(messages.count, 3)
XCTAssertEqual(messages.count, 2)

try await fixtures.alixClient.conversations.sync()
let sameDm = try await fixtures.alixClient.conversations.listDms().last!
Expand Down
6 changes: 3 additions & 3 deletions Tests/XMTPTests/GroupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ class GroupTests: XCTestCase {
let end = Date()
print(end.timeIntervalSince(start))
XCTAssert(end.timeIntervalSince(start) < 1)
XCTAssert(numGroupsSynced == 100)
XCTAssertEqual(numGroupsSynced, 101)
} catch {
print("Failed to list groups members: \(error)")
throw error // Rethrow the error to fail the test if group creation fails
Expand All @@ -973,12 +973,12 @@ class GroupTests: XCTestCase {
// first syncAllGroups after removal still sync groups in order to process the removal
var numGroupsSynced = try await fixtures.boClient.conversations
.syncAllConversations()
XCTAssert(numGroupsSynced == 100)
XCTAssertEqual(numGroupsSynced, 101)

// next syncAllGroups only will sync active groups
numGroupsSynced = try await fixtures.boClient.conversations
.syncAllConversations()
XCTAssert(numGroupsSynced == 0)
XCTAssertEqual(numGroupsSynced, 1)
}

func testCanListManyMembersInParallelInUnderASecond() async throws {
Expand Down
2 changes: 1 addition & 1 deletion Tests/XMTPTests/RemoteAttachmentTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class RemoteAttachmentTests: XCTestCase {
options: .init(contentType: ContentTypeRemoteAttachment))
let messages = try await conversation.messages()

XCTAssertEqual(2, messages.count)
XCTAssertEqual(1, messages.count)

let receivedMessage = messages[0]
var remoteAttachment: RemoteAttachment = try receivedMessage.content()
Expand Down
4 changes: 2 additions & 2 deletions XMTP.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |spec|
#

spec.name = "XMTP"
spec.version = "3.0.4"
spec.version = "3.0.5"
spec.summary = "XMTP SDK Cocoapod"

# This description is used to generate tags and improve search results.
Expand Down Expand Up @@ -44,5 +44,5 @@ Pod::Spec.new do |spec|
spec.dependency "web3.swift"
spec.dependency "GzipSwift"
spec.dependency "Connect-Swift", "= 0.12.0"
spec.dependency 'LibXMTP', '= 3.0.0'
spec.dependency 'LibXMTP', '= 3.0.1'
end
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/xmtp/libxmtp-swift.git",
"state" : {
"revision" : "83bd77f78de03b63cd35405567036875c3ca9b1c",
"version" : "3.0.0"
"revision" : "f495d4feaab40a0a6a48c1d5a99585de8107f5d2",
"version" : "3.0.1"
}
},
{
Expand Down

0 comments on commit 95f7910

Please sign in to comment.