Browse Source

feat: add hidden moderator and admin roles, separated as they may be used independently in future (#942)

pull/948/head
Harris 1 month ago committed by GitHub
parent
commit
5469f232a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      app/src/main/java/org/thoughtcrime/securesms/groups/OpenGroupManager.kt
  2. 2
      libsession/src/main/java/org/session/libsession/messaging/open_groups/GroupMember.kt
  3. 6
      libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/OpenGroupPoller.kt

8
app/src/main/java/org/thoughtcrime/securesms/groups/OpenGroupManager.kt

@ -148,8 +148,12 @@ object OpenGroupManager {
val standardRoles = memberDatabase.getGroupMemberRoles(groupId, standardPublicKey)
val blindedRoles = blindedPublicKey?.let { memberDatabase.getGroupMemberRoles(groupId, it) } ?: emptyList()
return GroupMemberRole.ADMIN in standardRoles || GroupMemberRole.MODERATOR in standardRoles ||
GroupMemberRole.ADMIN in blindedRoles || GroupMemberRole.MODERATOR in blindedRoles
// roles to check against
val moderatorRoles = listOf(
GroupMemberRole.MODERATOR, GroupMemberRole.ADMIN,
GroupMemberRole.HIDDEN_MODERATOR, GroupMemberRole.HIDDEN_ADMIN
)
return standardRoles.any { it in moderatorRoles } || blindedRoles.any { it in moderatorRoles }
}
}

2
libsession/src/main/java/org/session/libsession/messaging/open_groups/GroupMember.kt

@ -7,5 +7,5 @@ data class GroupMember(
)
enum class GroupMemberRole {
STANDARD, ZOOMBIE, MODERATOR, ADMIN
STANDARD, ZOOMBIE, MODERATOR, ADMIN, HIDDEN_MODERATOR, HIDDEN_ADMIN
}

6
libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/OpenGroupPoller.kt

@ -136,10 +136,16 @@ class OpenGroupPoller(private val server: String, private val executorService: S
pollInfo.details?.moderators?.forEach {
storage.addGroupMember(GroupMember(groupId, it, GroupMemberRole.MODERATOR))
}
pollInfo.details?.hiddenModerators?.forEach {
storage.addGroupMember(GroupMember(groupId, it, GroupMemberRole.HIDDEN_MODERATOR))
}
// - Admins
pollInfo.details?.admins?.forEach {
storage.addGroupMember(GroupMember(groupId, it, GroupMemberRole.ADMIN))
}
pollInfo.details?.hiddenAdmins?.forEach {
storage.addGroupMember(GroupMember(groupId, it, GroupMemberRole.HIDDEN_ADMIN))
}
}
private fun handleMessages(

Loading…
Cancel
Save