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

This commit is contained in:
Harris 2022-08-17 11:06:02 +10:00 committed by GitHub
parent e7ca53ff72
commit 5469f232a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View File

@ -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 }
}
}

View File

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

View File

@ -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(