From cb4914573f937003509292f7a3ff11afca9f5f97 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 25 Oct 2023 20:59:07 -0700 Subject: [PATCH] feat: add the swift side of PPPP --- ios/XMTPModule.swift | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/ios/XMTPModule.swift b/ios/XMTPModule.swift index 17c13e2ec..bd6ae9c77 100644 --- a/ios/XMTPModule.swift +++ b/ios/XMTPModule.swift @@ -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() + } } //