Skip to content

Commit

Permalink
add new group admin functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Feb 21, 2024
1 parent 867d1dc commit fc78da9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions library/src/main/java/org/xmtp/android/library/Group.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import org.xmtp.android.library.messages.DecryptedMessage
import org.xmtp.android.library.messages.PagingInfoSortDirection
import org.xmtp.proto.message.api.v1.MessageApiOuterClass
import uniffi.xmtpv3.FfiGroup
import uniffi.xmtpv3.FfiGroupMetadata
import uniffi.xmtpv3.FfiListMessagesOptions
import uniffi.xmtpv3.FfiMessage
import uniffi.xmtpv3.FfiMessageCallback
import uniffi.xmtpv3.GroupPermissions
import java.lang.Exception
import java.util.Date
import kotlin.time.Duration.Companion.nanoseconds
Expand All @@ -27,6 +29,9 @@ class Group(val client: Client, private val libXMTPGroup: FfiGroup) {
val createdAt: Date
get() = Date(libXMTPGroup.createdAtNs() / 1_000_000)

private val metadata: FfiGroupMetadata
get() = libXMTPGroup.groupMetadata()

fun send(text: String): String {
return send(prepareMessage(content = text, options = null))
}
Expand Down Expand Up @@ -133,6 +138,18 @@ class Group(val client: Client, private val libXMTPGroup: FfiGroup) {
return libXMTPGroup.isActive()
}

fun permissionLevel(): GroupPermissions {
return metadata.policyType()
}

fun isAdmin(): Boolean {
return metadata.creatorAccountAddress().lowercase() == client.address.lowercase()
}

fun adminAddress(): String {
return metadata.creatorAccountAddress()
}

fun addMembers(addresses: List<String>) {
try {
runBlocking { libXMTPGroup.addMembers(addresses) }
Expand Down

0 comments on commit fc78da9

Please sign in to comment.