-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #434 from xmtp/cv/latest-libxmtp-permissions-descr…
…iption-updates Latest libxmtp - permissions and description field updates
- Loading branch information
Showing
16 changed files
with
773 additions
and
91 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
37 changes: 37 additions & 0 deletions
37
android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/PermissionPolicySetWrapper.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,37 @@ | ||
package expo.modules.xmtpreactnativesdk.wrappers | ||
|
||
import com.google.gson.GsonBuilder | ||
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.PermissionOption | ||
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.PermissionPolicySet | ||
|
||
class PermissionPolicySetWrapper { | ||
|
||
companion object { | ||
fun fromPermissionOption(permissionOption: PermissionOption): String { | ||
return when (permissionOption) { | ||
PermissionOption.Allow -> "allow" | ||
PermissionOption.Deny -> "deny" | ||
PermissionOption.Admin -> "admin" | ||
PermissionOption.SuperAdmin -> "superAdmin" | ||
PermissionOption.Unknown -> "unknown" | ||
} | ||
} | ||
fun encodeToObj(policySet: PermissionPolicySet): Map<String, Any> { | ||
return mapOf( | ||
"addMemberPolicy" to fromPermissionOption(policySet.addMemberPolicy), | ||
"removeMemberPolicy" to fromPermissionOption(policySet.removeMemberPolicy), | ||
"addAdminPolicy" to fromPermissionOption(policySet.addAdminPolicy), | ||
"removeAdminPolicy" to fromPermissionOption(policySet.removeAdminPolicy), | ||
"updateGroupNamePolicy" to fromPermissionOption(policySet.updateGroupNamePolicy), | ||
"updateGroupDescriptionPolicy" to fromPermissionOption(policySet.updateGroupDescriptionPolicy), | ||
"updateGroupImagePolicy" to fromPermissionOption(policySet.updateGroupImagePolicy), | ||
) | ||
} | ||
|
||
fun encodeToJsonString(policySet: PermissionPolicySet): String { | ||
val gson = GsonBuilder().create() | ||
val obj = encodeToObj(policySet) | ||
return gson.toJson(obj) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.