Skip to content

Commit

Permalink
add delivery status to filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Apr 18, 2024
1 parent 88b2d85 commit 0f6f821
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions Sources/XMTPiOS/Group.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,28 @@ public struct Group: Identifiable, Equatable, Hashable {
}
}

public func messages(before: Date? = nil, after: Date? = nil, limit: Int? = nil, direction: PagingInfoSortDirection? = .descending) async throws -> [DecodedMessage] {
var options = FfiListMessagesOptions(sentBeforeNs: nil, sentAfterNs: nil, limit: nil)
public func messages(
before: Date? = nil,
after: Date? = nil,
limit: Int? = nil,
direction: PagingInfoSortDirection? = .descending,
deliveryStatus: MessageDeliveryStatus? = .all
) async throws -> [DecodedMessage] {
var options = FfiListMessagesOptions(
sentBeforeNs: nil,
sentAfterNs: nil,
limit: nil,
deliveryStatus: switch deliveryStatus {
case .published:
deliveryStatus = .published
case .unpublished:
deliveryStatus = .unpublished
case .failed:
deliveryStatus = .failed
default:
deliveryStatus = nil
}
)

if let before {
options.sentBeforeNs = Int64(before.millisecondsSinceEpoch * 1_000_000)
Expand All @@ -240,8 +260,28 @@ public struct Group: Identifiable, Equatable, Hashable {
}
}

public func decryptedMessages(before: Date? = nil, after: Date? = nil, limit: Int? = nil, direction: PagingInfoSortDirection? = .descending) async throws -> [DecryptedMessage] {
var options = FfiListMessagesOptions(sentBeforeNs: nil, sentAfterNs: nil, limit: nil)
public func decryptedMessages(
before: Date? = nil,
after: Date? = nil,
limit: Int? = nil,
direction: PagingInfoSortDirection? = .descending,
deliveryStatus: MessageDeliveryStatus? = .all
) async throws -> [DecryptedMessage] {
var options = FfiListMessagesOptions(
sentBeforeNs: nil,
sentAfterNs: nil,
limit: nil
deliveryStatus: switch deliveryStatus {
case .published:
deliveryStatus = .published
case .unpublished:
deliveryStatus = .unpublished
case .failed:
deliveryStatus = .failed
default:
deliveryStatus = nil
}
)

if let before {
options.sentBeforeNs = Int64(before.millisecondsSinceEpoch * 1_000_000)
Expand Down

0 comments on commit 0f6f821

Please sign in to comment.