-
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.
add ability to list group members in android
- Loading branch information
1 parent
59505df
commit b3a84df
Showing
3 changed files
with
39 additions
and
0 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
28 changes: 28 additions & 0 deletions
28
android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/MemberWrapper.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,28 @@ | ||
package expo.modules.xmtpreactnativesdk.wrappers | ||
|
||
import com.google.gson.GsonBuilder | ||
import org.xmtp.android.library.libxmtp.Member | ||
import org.xmtp.android.library.libxmtp.PermissionLevel | ||
|
||
class MemberWrapper { | ||
companion object { | ||
fun encodeToObj(member: Member): Map<String, Any> { | ||
val permissionString = when (member.permissionLevel) { | ||
PermissionLevel.MEMBER -> "member" | ||
PermissionLevel.ADMIN -> "admin" | ||
PermissionLevel.SUPER_ADMIN -> "super_admin" | ||
} | ||
return mapOf( | ||
"inboxId" to member.inboxId, | ||
"addresses" to member.addresses, | ||
"permissionLevel" to permissionString | ||
) | ||
} | ||
|
||
fun encode(member: Member): String { | ||
val gson = GsonBuilder().create() | ||
val obj = encodeToObj(member) | ||
return gson.toJson(obj) | ||
} | ||
} | ||
} |