Skip to content

Commit

Permalink
Merge pull request #30 from xmtp/cv/permissions-admin-super-admin-lists
Browse files Browse the repository at this point in the history
updated for admin, super admin lists from libxmtp
  • Loading branch information
cameronvoell authored May 29, 2024
2 parents 4b534c8 + ba7bcb6 commit e4e5aeb
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 13 deletions.
4 changes: 2 additions & 2 deletions LibXMTP.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'LibXMTP'
s.version = '0.5.0-beta0'
s.version = '0.5.0-beta1'
s.summary = 'XMTP shared Rust code that powers cross-platform SDKs'

s.homepage = 'https://github.com/xmtp/libxmtp-swift'
Expand All @@ -10,7 +10,7 @@ Pod::Spec.new do |s|
s.platform = :ios, '13.0', :macos, '11.0'
s.swift_version = '5.3'

s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-ca024cb/LibXMTPSwiftFFI.zip", :type => :zip }
s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-c86272d/LibXMTPSwiftFFI.zip", :type => :zip }
s.vendored_frameworks = 'LibXMTPSwiftFFI.xcframework'
s.source_files = 'Sources/LibXMTP/**/*'
end
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ let package = Package(
),
.binaryTarget(
name: "LibXMTPSwiftFFI",
url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-ca024cb/LibXMTPSwiftFFI.zip",
checksum: "2e06d57a14c849e89803c2294d46c4f09ae6d7797153ebbd510194adc6c42852"
url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-c86272d/LibXMTPSwiftFFI.zip",
checksum: "c9a5fdc8ffc936f1f3901cb3cb3aedea06782a68d962ef498696fd7e4f888c48"
),
.testTarget(name: "LibXMTPTests", dependencies: ["LibXMTP"]),
]
Expand Down
6 changes: 3 additions & 3 deletions Sources/LibXMTP/libxmtp-version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: ca024cbb
Branch: main
Date: 2024-05-24 20:35:12 +0000
Version: c86272d
Branch: HEAD
Date: 2024-05-28 21:11:59 +0000
157 changes: 151 additions & 6 deletions Sources/LibXMTP/xmtpv3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -691,12 +691,18 @@ public func FfiConverterTypeFfiConversations_lower(_ value: FfiConversations) ->
}

public protocol FfiGroupProtocol: AnyObject {
func addAdmin(inboxId: String) async throws

func addMembers(accountAddresses: [String]) async throws

func addMembersByInboxId(inboxIds: [String]) async throws

func addSuperAdmin(inboxId: String) async throws

func addedByInboxId() throws -> String

func adminList() throws -> [String]

func createdAtNs() -> Int64

func findMessages(opts: FfiListMessagesOptions) throws -> [FfiMessage]
Expand All @@ -705,22 +711,34 @@ public protocol FfiGroupProtocol: AnyObject {

func groupName() throws -> String

func groupPermissions() throws -> FfiGroupPermissions

func id() -> Data

func isActive() throws -> Bool

func isAdmin(inboxId: String) throws -> Bool

func isSuperAdmin(inboxId: String) throws -> Bool

func listMembers() throws -> [FfiGroupMember]

func processStreamedGroupMessage(envelopeBytes: Data) async throws -> FfiMessage

func removeAdmin(inboxId: String) async throws

func removeMembers(accountAddresses: [String]) async throws

func removeMembersByInboxId(inboxIds: [String]) async throws

func removeSuperAdmin(inboxId: String) async throws

func send(contentBytes: Data) async throws -> Data

func stream(messageCallback: FfiMessageCallback) async throws -> FfiStreamCloser

func superAdminList() throws -> [String]

func sync() async throws

func updateGroupName(groupName: String) async throws
Expand Down Expand Up @@ -766,6 +784,23 @@ open class FfiGroup:
try! rustCall { uniffi_xmtpv3_fn_free_ffigroup(pointer, $0) }
}

open func addAdmin(inboxId: String) async throws {
return
try await uniffiRustCallAsync(
rustFutureFunc: {
uniffi_xmtpv3_fn_method_ffigroup_add_admin(
self.uniffiClonePointer(),
FfiConverterString.lower(inboxId)
)
},
pollFunc: ffi_xmtpv3_rust_future_poll_void,
completeFunc: ffi_xmtpv3_rust_future_complete_void,
freeFunc: ffi_xmtpv3_rust_future_free_void,
liftFunc: { $0 },
errorHandler: FfiConverterTypeGenericError.lift
)
}

open func addMembers(accountAddresses: [String]) async throws {
return
try await uniffiRustCallAsync(
Expand Down Expand Up @@ -800,12 +835,35 @@ open class FfiGroup:
)
}

open func addSuperAdmin(inboxId: String) async throws {
return
try await uniffiRustCallAsync(
rustFutureFunc: {
uniffi_xmtpv3_fn_method_ffigroup_add_super_admin(
self.uniffiClonePointer(),
FfiConverterString.lower(inboxId)
)
},
pollFunc: ffi_xmtpv3_rust_future_poll_void,
completeFunc: ffi_xmtpv3_rust_future_complete_void,
freeFunc: ffi_xmtpv3_rust_future_free_void,
liftFunc: { $0 },
errorHandler: FfiConverterTypeGenericError.lift
)
}

open func addedByInboxId() throws -> String {
return try FfiConverterString.lift(rustCallWithError(FfiConverterTypeGenericError.lift) {
uniffi_xmtpv3_fn_method_ffigroup_added_by_inbox_id(self.uniffiClonePointer(), $0)
})
}

open func adminList() throws -> [String] {
return try FfiConverterSequenceString.lift(rustCallWithError(FfiConverterTypeGenericError.lift) {
uniffi_xmtpv3_fn_method_ffigroup_admin_list(self.uniffiClonePointer(), $0)
})
}

open func createdAtNs() -> Int64 {
return try! FfiConverterInt64.lift(try! rustCall {
uniffi_xmtpv3_fn_method_ffigroup_created_at_ns(self.uniffiClonePointer(), $0)
Expand All @@ -831,6 +889,12 @@ open class FfiGroup:
})
}

open func groupPermissions() throws -> FfiGroupPermissions {
return try FfiConverterTypeFfiGroupPermissions.lift(rustCallWithError(FfiConverterTypeGenericError.lift) {
uniffi_xmtpv3_fn_method_ffigroup_group_permissions(self.uniffiClonePointer(), $0)
})
}

open func id() -> Data {
return try! FfiConverterData.lift(try! rustCall {
uniffi_xmtpv3_fn_method_ffigroup_id(self.uniffiClonePointer(), $0)
Expand All @@ -843,6 +907,20 @@ open class FfiGroup:
})
}

open func isAdmin(inboxId: String) throws -> Bool {
return try FfiConverterBool.lift(rustCallWithError(FfiConverterTypeGenericError.lift) {
uniffi_xmtpv3_fn_method_ffigroup_is_admin(self.uniffiClonePointer(),
FfiConverterString.lower(inboxId), $0)
})
}

open func isSuperAdmin(inboxId: String) throws -> Bool {
return try FfiConverterBool.lift(rustCallWithError(FfiConverterTypeGenericError.lift) {
uniffi_xmtpv3_fn_method_ffigroup_is_super_admin(self.uniffiClonePointer(),
FfiConverterString.lower(inboxId), $0)
})
}

open func listMembers() throws -> [FfiGroupMember] {
return try FfiConverterSequenceTypeFfiGroupMember.lift(rustCallWithError(FfiConverterTypeGenericError.lift) {
uniffi_xmtpv3_fn_method_ffigroup_list_members(self.uniffiClonePointer(), $0)
Expand All @@ -866,6 +944,23 @@ open class FfiGroup:
)
}

open func removeAdmin(inboxId: String) async throws {
return
try await uniffiRustCallAsync(
rustFutureFunc: {
uniffi_xmtpv3_fn_method_ffigroup_remove_admin(
self.uniffiClonePointer(),
FfiConverterString.lower(inboxId)
)
},
pollFunc: ffi_xmtpv3_rust_future_poll_void,
completeFunc: ffi_xmtpv3_rust_future_complete_void,
freeFunc: ffi_xmtpv3_rust_future_free_void,
liftFunc: { $0 },
errorHandler: FfiConverterTypeGenericError.lift
)
}

open func removeMembers(accountAddresses: [String]) async throws {
return
try await uniffiRustCallAsync(
Expand Down Expand Up @@ -900,6 +995,23 @@ open class FfiGroup:
)
}

open func removeSuperAdmin(inboxId: String) async throws {
return
try await uniffiRustCallAsync(
rustFutureFunc: {
uniffi_xmtpv3_fn_method_ffigroup_remove_super_admin(
self.uniffiClonePointer(),
FfiConverterString.lower(inboxId)
)
},
pollFunc: ffi_xmtpv3_rust_future_poll_void,
completeFunc: ffi_xmtpv3_rust_future_complete_void,
freeFunc: ffi_xmtpv3_rust_future_free_void,
liftFunc: { $0 },
errorHandler: FfiConverterTypeGenericError.lift
)
}

open func send(contentBytes: Data) async throws -> Data {
return
try await uniffiRustCallAsync(
Expand Down Expand Up @@ -934,6 +1046,12 @@ open class FfiGroup:
)
}

open func superAdminList() throws -> [String] {
return try FfiConverterSequenceString.lift(rustCallWithError(FfiConverterTypeGenericError.lift) {
uniffi_xmtpv3_fn_method_ffigroup_super_admin_list(self.uniffiClonePointer(), $0)
})
}

open func sync() async throws {
return
try await uniffiRustCallAsync(
Expand Down Expand Up @@ -2929,8 +3047,8 @@ extension GenericError: Error {}
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.

public enum GroupPermissions {
case everyoneIsAdmin
case groupCreatorIsAdmin
case allMembers
case adminOnly
}

public struct FfiConverterTypeGroupPermissions: FfiConverterRustBuffer {
Expand All @@ -2939,20 +3057,20 @@ public struct FfiConverterTypeGroupPermissions: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GroupPermissions {
let variant: Int32 = try readInt(&buf)
switch variant {
case 1: return .everyoneIsAdmin
case 1: return .allMembers

case 2: return .groupCreatorIsAdmin
case 2: return .adminOnly

default: throw UniffiInternalError.unexpectedEnumCase
}
}

public static func write(_ value: GroupPermissions, into buf: inout [UInt8]) {
switch value {
case .everyoneIsAdmin:
case .allMembers:
writeInt(&buf, Int32(1))

case .groupCreatorIsAdmin:
case .adminOnly:
writeInt(&buf, Int32(2))
}
}
Expand Down Expand Up @@ -4037,15 +4155,24 @@ private var initializationResult: InitializationResult {
if uniffi_xmtpv3_checksum_method_fficonversations_sync() != 9054 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_add_admin() != 4600 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_add_members() != 27666 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_add_members_by_inbox_id() != 23290 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_add_super_admin() != 40681 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_added_by_inbox_id() != 37220 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_admin_list() != 51010 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_created_at_ns() != 4894 {
return InitializationResult.apiChecksumMismatch
}
Expand All @@ -4058,30 +4185,48 @@ private var initializationResult: InitializationResult {
if uniffi_xmtpv3_checksum_method_ffigroup_group_name() != 61525 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_group_permissions() != 15980 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_id() != 36764 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_is_active() != 33848 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_is_admin() != 26672 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_is_super_admin() != 61614 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_list_members() != 61034 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_process_streamed_group_message() != 19069 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_remove_admin() != 57094 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_remove_members() != 24336 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_remove_members_by_inbox_id() != 45424 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_remove_super_admin() != 35336 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_send() != 37701 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_stream() != 45558 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_super_admin_list() != 5323 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroup_sync() != 24219 {
return InitializationResult.apiChecksumMismatch
}
Expand Down

0 comments on commit e4e5aeb

Please sign in to comment.