Skip to content

Commit

Permalink
adds messageExpiration permissions from libxmtp (#368)
Browse files Browse the repository at this point in the history
Co-authored-by: cameronvoell <[email protected]>
  • Loading branch information
cameronvoell and cameronvoell authored Jan 15, 2025
1 parent 2da80a0 commit fc83757
Show file tree
Hide file tree
Showing 9 changed files with 3,658 additions and 4,673 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ class GroupPermissionsTest {
updateGroupDescriptionPolicy = PermissionOption.Allow,
updateGroupImagePolicy = PermissionOption.Admin,
updateGroupPinnedFrameUrlPolicy = PermissionOption.Deny,
updateMessageExpirationPolicy = PermissionOption.Admin,
)
val boGroup = runBlocking {
boClient.conversations.newGroupCustomPermissions(
Expand Down Expand Up @@ -468,6 +469,7 @@ class GroupPermissionsTest {
updateGroupDescriptionPolicy = PermissionOption.Allow,
updateGroupImagePolicy = PermissionOption.Admin,
updateGroupPinnedFrameUrlPolicy = PermissionOption.Deny,
updateMessageExpirationPolicy = PermissionOption.Admin,
)

assertThrows(GenericException.GroupMutablePermissions::class.java) {
Expand All @@ -488,6 +490,7 @@ class GroupPermissionsTest {
updateGroupDescriptionPolicy = PermissionOption.Allow,
updateGroupImagePolicy = PermissionOption.Admin,
updateGroupPinnedFrameUrlPolicy = PermissionOption.Deny,
updateMessageExpirationPolicy = PermissionOption.Allow,
)

// Valid custom policy works as expected
Expand Down
4 changes: 2 additions & 2 deletions library/src/main/java/libxmtp-version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: ab9bb055
Version: f04e0049
Branch: main
Date: 2025-01-07 00:08:33 +0000
Date: 2025-01-14 23:09:48 +0000
18 changes: 15 additions & 3 deletions library/src/main/java/org/xmtp/android/library/Conversations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ data class Conversations(
groupImageUrlSquare: String = "",
groupDescription: String = "",
groupPinnedFrameUrl: String = "",
messageExpirationFromMs: Long? = null,
messageExpirationMs: Long? = null,
): Group {
return newGroupInternal(
accountAddresses,
Expand All @@ -62,7 +64,9 @@ data class Conversations(
groupImageUrlSquare,
groupDescription,
groupPinnedFrameUrl,
null
null,
messageExpirationFromMs,
messageExpirationMs,
)
}

Expand All @@ -73,6 +77,8 @@ data class Conversations(
groupImageUrlSquare: String = "",
groupDescription: String = "",
groupPinnedFrameUrl: String = "",
messageExpirationFromMs: Long? = null,
messageExpirationMs: Long? = null,
): Group {
return newGroupInternal(
accountAddresses,
Expand All @@ -81,7 +87,9 @@ data class Conversations(
groupImageUrlSquare,
groupDescription,
groupPinnedFrameUrl,
PermissionPolicySet.toFfiPermissionPolicySet(permissionPolicySet)
PermissionPolicySet.toFfiPermissionPolicySet(permissionPolicySet),
messageExpirationFromMs,
messageExpirationMs
)
}

Expand All @@ -93,6 +101,8 @@ data class Conversations(
groupDescription: String,
groupPinnedFrameUrl: String,
permissionsPolicySet: FfiPermissionPolicySet?,
messageExpirationFromMs: Long?,
messageExpirationMs: Long?,
): Group {
if (accountAddresses.size == 1 &&
accountAddresses.first().lowercase() == client.address.lowercase()
Expand All @@ -115,7 +125,9 @@ data class Conversations(
groupImageUrlSquare = groupImageUrlSquare,
groupDescription = groupDescription,
groupPinnedFrameUrl = groupPinnedFrameUrl,
customPermissionPolicySet = permissionsPolicySet
customPermissionPolicySet = permissionsPolicySet,
messageExpirationFromMs = messageExpirationFromMs,
messageExpirationMs = messageExpirationMs,
)
)
return Group(client.inboxId, group)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ enum class GroupPermissionPreconfiguration {
companion object {
fun toFfiGroupPermissionOptions(option: GroupPermissionPreconfiguration): FfiGroupPermissionsOptions {
return when (option) {
ALL_MEMBERS -> FfiGroupPermissionsOptions.ALL_MEMBERS
ALL_MEMBERS -> FfiGroupPermissionsOptions.DEFAULT
ADMIN_ONLY -> FfiGroupPermissionsOptions.ADMIN_ONLY
}
}
Expand All @@ -55,6 +55,7 @@ data class PermissionPolicySet(
val updateGroupDescriptionPolicy: PermissionOption,
val updateGroupImagePolicy: PermissionOption,
val updateGroupPinnedFrameUrlPolicy: PermissionOption,
val updateMessageExpirationPolicy: PermissionOption,
) {
companion object {
fun toFfiPermissionPolicySet(permissionPolicySet: PermissionPolicySet): FfiPermissionPolicySet {
Expand All @@ -66,7 +67,8 @@ data class PermissionPolicySet(
updateGroupNamePolicy = PermissionOption.toFfiPermissionPolicy(permissionPolicySet.updateGroupNamePolicy),
updateGroupDescriptionPolicy = PermissionOption.toFfiPermissionPolicy(permissionPolicySet.updateGroupDescriptionPolicy),
updateGroupImageUrlSquarePolicy = PermissionOption.toFfiPermissionPolicy(permissionPolicySet.updateGroupImagePolicy),
updateGroupPinnedFrameUrlPolicy = PermissionOption.toFfiPermissionPolicy(permissionPolicySet.updateGroupPinnedFrameUrlPolicy)
updateGroupPinnedFrameUrlPolicy = PermissionOption.toFfiPermissionPolicy(permissionPolicySet.updateGroupPinnedFrameUrlPolicy),
updateMessageExpirationMsPolicy = PermissionOption.toFfiPermissionPolicy(permissionPolicySet.updateMessageExpirationPolicy),
)
}

Expand All @@ -80,6 +82,7 @@ data class PermissionPolicySet(
updateGroupDescriptionPolicy = PermissionOption.fromFfiPermissionPolicy(ffiPermissionPolicySet.updateGroupDescriptionPolicy),
updateGroupImagePolicy = PermissionOption.fromFfiPermissionPolicy(ffiPermissionPolicySet.updateGroupImageUrlSquarePolicy),
updateGroupPinnedFrameUrlPolicy = PermissionOption.fromFfiPermissionPolicy(ffiPermissionPolicySet.updateGroupPinnedFrameUrlPolicy),
updateMessageExpirationPolicy = PermissionOption.fromFfiPermissionPolicy(ffiPermissionPolicySet.updateMessageExpirationMsPolicy)
)
}
}
Expand Down
Loading

0 comments on commit fc83757

Please sign in to comment.