-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Latest libxmtp - permissions and description field updates (#267)
* update libxmtp bindings * format bindings file * update bindings fields * lint fix * Add group description functions, fix import * Added functions for reading and updating group permissions * fixed tests * lint fix * Added test for updating permissions and description * fix lint error * remove unused enum --------- Co-authored-by: cameronvoell <[email protected]>
- Loading branch information
1 parent
2f763bd
commit 2d1bbac
Showing
11 changed files
with
587 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Version: feb48641 | ||
Version: e4cfade7 | ||
Branch: main | ||
Date: 2024-06-26 22:31:21 +0000 | ||
Date: 2024-07-01 19:23:57 +0000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
library/src/main/java/org/xmtp/android/library/libxmtp/PermissionPolicySet.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package uniffi.xmtpv3.org.xmtp.android.library.libxmtp | ||
|
||
import uniffi.xmtpv3.FfiGroupPermissionsOptions | ||
import uniffi.xmtpv3.FfiPermissionPolicy | ||
import uniffi.xmtpv3.FfiPermissionPolicySet | ||
enum class PermissionOption { | ||
Allow, | ||
Deny, | ||
Admin, | ||
SuperAdmin, | ||
Unknown; | ||
companion object { | ||
fun toFfiPermissionPolicy(option: PermissionOption): FfiPermissionPolicy { | ||
return when (option) { | ||
Allow -> FfiPermissionPolicy.ALLOW | ||
Deny -> FfiPermissionPolicy.DENY | ||
Admin -> FfiPermissionPolicy.ADMIN | ||
SuperAdmin -> FfiPermissionPolicy.SUPER_ADMIN | ||
Unknown -> FfiPermissionPolicy.OTHER | ||
} | ||
} | ||
fun fromFfiPermissionPolicy(ffiPolicy: FfiPermissionPolicy): PermissionOption { | ||
return when (ffiPolicy) { | ||
FfiPermissionPolicy.ALLOW -> Allow | ||
FfiPermissionPolicy.DENY -> Deny | ||
FfiPermissionPolicy.ADMIN -> Admin | ||
FfiPermissionPolicy.SUPER_ADMIN -> SuperAdmin | ||
FfiPermissionPolicy.DOES_NOT_EXIST -> Unknown | ||
FfiPermissionPolicy.OTHER -> Unknown | ||
} | ||
} | ||
} | ||
} | ||
|
||
enum class GroupPermissionPreconfiguration { | ||
ALL_MEMBERS, | ||
ADMIN_ONLY; | ||
|
||
companion object { | ||
fun toFfiGroupPermissionOptions(option: GroupPermissionPreconfiguration): FfiGroupPermissionsOptions { | ||
return when (option) { | ||
ALL_MEMBERS -> FfiGroupPermissionsOptions.ALL_MEMBERS | ||
ADMIN_ONLY -> FfiGroupPermissionsOptions.ADMIN_ONLY | ||
} | ||
} | ||
} | ||
} | ||
|
||
class PermissionPolicySet(private val ffiPermissionPolicySet: FfiPermissionPolicySet) { | ||
val addMemberPolicy: PermissionOption | ||
get() = PermissionOption.fromFfiPermissionPolicy(ffiPermissionPolicySet.addMemberPolicy) | ||
val removeMemberPolicy: PermissionOption | ||
get() = PermissionOption.fromFfiPermissionPolicy(ffiPermissionPolicySet.removeMemberPolicy) | ||
val addAdminPolicy: PermissionOption | ||
get() = PermissionOption.fromFfiPermissionPolicy(ffiPermissionPolicySet.addAdminPolicy) | ||
val removeAdminPolicy: PermissionOption | ||
get() = PermissionOption.fromFfiPermissionPolicy(ffiPermissionPolicySet.removeAdminPolicy) | ||
val updateGroupNamePolicy: PermissionOption | ||
get() = PermissionOption.fromFfiPermissionPolicy(ffiPermissionPolicySet.updateGroupNamePolicy) | ||
val updateGroupDescriptionPolicy: PermissionOption | ||
get() = PermissionOption.fromFfiPermissionPolicy(ffiPermissionPolicySet.updateGroupDescriptionPolicy) | ||
val updateGroupImagePolicy: PermissionOption | ||
get() = PermissionOption.fromFfiPermissionPolicy(ffiPermissionPolicySet.updateGroupImageUrlSquarePolicy) | ||
} |
Oops, something went wrong.