Skip to content

Commit

Permalink
feat: add the swift side of PPPP
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Oct 26, 2023
1 parent e16673e commit cb49145
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,41 @@ public class XMTPModule: Module {
let decodedMessage = try conversation.decode(envelope)
return try DecodedMessageWrapper.encode(decodedMessage)
}

AsyncFunction("isAllowed") { (clientAddress: String, address: String) -> Bool in
guard let client = await clientsManager.getClient(key: clientAddress) else {
throw Error.noClient
}
return await client.contacts.isAllowed(address: address)
}

AsyncFunction("isBlocked") { (clientAddress: String, address: String) -> Bool in
guard let client = await clientsManager.getClient(key: clientAddress) else {
throw Error.noClient
}
return await client.contacts.isBlocked(address: address)
}

AsyncFunction("blockContacts") { (clientAddress: String, addresses: [String]) in
guard let client = await clientsManager.getClient(key: clientAddress) else {
throw Error.noClient
}
return try await client.contacts.block(addresses: addresses)
}

AsyncFunction("allowContacts") { (clientAddress: String, addresses: [String]) in
guard let client = await clientsManager.getClient(key: clientAddress) else {
throw Error.noClient
}
return try await client.contacts.allow(addresses: addresses)
}

AsyncFunction("refreshAllowList") { (clientAddress: String) in
guard let client = await clientsManager.getClient(key: clientAddress) else {
throw Error.noClient
}
return try await client.contacts.refreshAllowList()
}
}

//
Expand Down

0 comments on commit cb49145

Please sign in to comment.