Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update jigasi detection #1200

Merged
merged 3 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ interface ChatRoomMember {
/** The last [Presence] packet received for this member (or null it if no presence has been received yet) */
val presence: Presence?

val isRobot: Boolean
val isJigasi: Boolean
val isTranscriber: Boolean
val isJibri: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import org.jitsi.xmpp.extensions.jitsimeet.JitsiParticipantRegionPacketExtension
import org.jitsi.xmpp.extensions.jitsimeet.StartMutedPacketExtension
import org.jitsi.xmpp.extensions.jitsimeet.StatsId
import org.jitsi.xmpp.extensions.jitsimeet.TranscriptionStatusExtension
import org.jitsi.xmpp.extensions.jitsimeet.UserInfoPacketExt
import org.jitsi.xmpp.extensions.jitsimeet.VideoMutedExtension
import org.jivesoftware.smack.packet.Presence
import org.jivesoftware.smack.packet.StandardExtensionElement
Expand Down Expand Up @@ -98,13 +97,6 @@ class ChatRoomMemberImpl(
}
private set

private var robot = false
override val isRobot: Boolean
get() {
// Jigasi and Jibri do not use the "robot" signaling, but semantically they should be considered "robots".
return robot || isJigasi || isJibri
}

private fun updateSourceInfo(presence: Presence) {
val sourceInfo = presence.getExtension<StandardExtensionElement>("SourceInfo", "jabber:client")
if (sourceInfo == null) {
Expand Down Expand Up @@ -156,13 +148,6 @@ class ChatRoomMemberImpl(

val firstPresence = (this.presence == null)
this.presence = presence
presence.getExtension(UserInfoPacketExt::class.java)?.let {
val newStatus = it.isRobot
if (newStatus != null && robot != newStatus) {
logger.debug { "robot: $robot" }
robot = newStatus
}
}

presence.getExtension(CapsExtension::class.java)?.let {
capsNodeVer = "${it.node}#${it.ver}"
Expand All @@ -173,17 +158,25 @@ class ChatRoomMemberImpl(
// We recognize jigasi by the existence of a "feature" extension in its presence.
val features = presence.getExtension(FeaturesExtension::class.java)
if (features != null) {
isJigasi = features.featureExtensions.any { it.`var` == "http://jitsi.org/protocol/jigasi" }
if (features.featureExtensions.any { it.`var` == "http://jitsi.org/protocol/jibri" }) {
isJibri = isJidTrusted().also {
if (!it) {
val domain = jid?.asDomainBareJid()
logger.warn(
"Jibri signaled from a non-trusted domain ($domain). The domain can be " +
"configured as trusted with the jicofo.xmpp.trusted-domains property."
)
}
}
val domain = jid?.asDomainBareJid()
val jidTrusted = domain != null && XmppConfig.config.trustedDomains.contains(domain)
val jibriSignaled = features.featureExtensions.any { it.`var` == "http://jitsi.org/protocol/jibri" }
val jigasiSignaled = features.featureExtensions.any { it.`var` == "http://jitsi.org/protocol/jigasi" }

isJibri = jibriSignaled && jidTrusted
isJigasi = jigasiSignaled && jidTrusted

if (jibriSignaled && !jidTrusted) {
logger.warn(
"Jibri signaled from a non-trusted domain ($domain). The domain can be " +
"configured as trusted with the jicofo.xmpp.trusted-domains property."
)
}
if (jigasiSignaled && !jidTrusted) {
logger.warn(
"Jigasi signaled from a non-trusted domain ($domain). The domain can be " +
"configured as trusted with the jicofo.xmpp.trusted-domains property."
)
}
} else {
isJigasi = false
Expand Down Expand Up @@ -248,14 +241,6 @@ class ChatRoomMemberImpl(
}
}

/**
* Whether this member is a trusted entity (logged in to one of the pre-configured trusted domains).
*/
private fun isJidTrusted() = jid?.let { XmppConfig.config.trustedDomains.contains(it.asDomainBareJid()) } ?: false

/**
* {@inheritDoc}
*/
override fun toString() = "ChatMember[id=$name role=$role]"

override val features: Set<Features> by lazy {
Expand All @@ -273,9 +258,9 @@ class ChatRoomMemberImpl(
this["region"] = region.toString()
this["occupant_jid"] = occupantJid.toString()
this["jid"] = jid.toString()
this["robot"] = robot
this["is_jibri"] = isJibri
this["is_jigasi"] = isJigasi
this["is_transcriber"] = isTranscriber
this["role"] = role.toString()
this["video_codecs"] = JSONArray().apply { videoCodecs?.let { addAll(it) } }
this["stats_id"] = statsId.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ class AutoOwnerRoleManager(chatRoom: ChatRoom) : ChatRoomRoleManager(chatRoom) {
return@add
}

owner = chatRoom.members.find { !it.isRobot && it.role.hasOwnerRights() }
owner = chatRoom.members.find { !(it.isJibri || it.isJigasi) && it.role.hasOwnerRights() }
if (owner != null) {
return@add
}

val newOwner = chatRoom.members.find { !it.isRobot && it.role != MemberRole.VISITOR }
val newOwner = chatRoom.members.find { !(it.isJibri || it.isJigasi) && it.role != MemberRole.VISITOR }
if (newOwner != null) {
logger.info("Electing new owner: $newOwner")
chatRoom.grantOwnership(newOwner)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ class JibriChatRoomMember(
override val name: String get() = TODO("Not yet implemented")
override val jid: Jid? get() = TODO("Not yet implemented")
override val sourceInfos: Set<SourceInfo> get() = TODO("Not yet implemented")
override val isRobot: Boolean get() = TODO("Not yet implemented")
override val isJigasi: Boolean get() = TODO("Not yet implemented")
override val isTranscriber: Boolean get() = TODO("Not yet implemented")
override val isJibri: Boolean get() = TODO("Not yet implemented")
Expand Down
Loading