Skip to content

Commit

Permalink
Merge branch 'main' into 12-16-update_libxmtp_ref_for_fork_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronvoell committed Dec 17, 2024
2 parents 6fde0db + 5d68efc commit a1a7e07
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
21 changes: 17 additions & 4 deletions Sources/XMTPiOS/Conversation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ public enum Conversation: Identifiable, Equatable, Hashable {
}
}

public func prepareMessage(encodedContent: EncodedContent) async throws
-> String
{
switch self {
case let .group(group):
return try await group.prepareMessage(
encodedContent: encodedContent)
case let .dm(dm):
return try await dm.prepareMessage(encodedContent: encodedContent)
}
}

public func prepareMessage<T>(content: T, options: SendOptions? = nil)
async throws -> String
{
Expand All @@ -92,7 +104,7 @@ public enum Conversation: Identifiable, Equatable, Hashable {
content: content, options: options)
}
}

public func publishMessages() async throws {
switch self {
case let .group(group):
Expand Down Expand Up @@ -132,13 +144,14 @@ public enum Conversation: Identifiable, Equatable, Hashable {
}

@discardableResult public func send(
encodedContent: EncodedContent) async throws -> String {
encodedContent: EncodedContent
) async throws -> String {
switch self {
case let .group(group):
return try await group.send(
encodedContent: encodedContent)
encodedContent: encodedContent)
case let .dm(dm):
return try await dm.send(encodedContent: encodedContent)
return try await dm.send(encodedContent: encodedContent)
}
}

Expand Down
12 changes: 12 additions & 0 deletions Sources/XMTPiOS/Dm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ public struct Dm: Identifiable, Equatable, Hashable {
return encoded
}

public func prepareMessage(encodedContent: EncodedContent) async throws
-> String
{
if try consentState() == .unknown {
try await updateConsentState(state: .allowed)
}

let messageId = try ffiConversation.sendOptimistic(
contentBytes: encodedContent.serializedData())
return messageId.toHex
}

public func prepareMessage<T>(content: T, options: SendOptions? = nil)
async throws -> String
{
Expand Down
12 changes: 12 additions & 0 deletions Sources/XMTPiOS/Group.swift
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,18 @@ public struct Group: Identifiable, Equatable, Hashable {
return encoded
}

public func prepareMessage(encodedContent: EncodedContent) async throws
-> String
{
if try consentState() == .unknown {
try await updateConsentState(state: .allowed)
}

let messageId = try ffiGroup.sendOptimistic(
contentBytes: encodedContent.serializedData())
return messageId.toHex
}

public func prepareMessage<T>(content: T, options: SendOptions? = nil)
async throws -> String
{
Expand Down
1 change: 1 addition & 0 deletions XMTP.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Pod::Spec.new do |spec|
spec.name = "XMTP"
spec.version = "3.0.17"

spec.summary = "XMTP SDK Cocoapod"

spec.description = <<-DESC
Expand Down

0 comments on commit a1a7e07

Please sign in to comment.