diff --git a/src/main/java/org/jitsi/jicofo/conference/JitsiMeetConference.java b/src/main/java/org/jitsi/jicofo/conference/JitsiMeetConference.java
index 36f980832a..1c2a5e1a98 100644
--- a/src/main/java/org/jitsi/jicofo/conference/JitsiMeetConference.java
+++ b/src/main/java/org/jitsi/jicofo/conference/JitsiMeetConference.java
@@ -68,7 +68,7 @@ public interface JitsiMeetConference
* Returns ChatRoom2 instance for the MUC this instance is
* currently in or null if it isn't in any.
*/
- ChatRoom getChatRoom();
+ @Nullable ChatRoom getChatRoom();
default JibriRecorder getJibriRecorder()
{
diff --git a/src/main/java/org/jitsi/jicofo/conference/JitsiMeetConferenceImpl.java b/src/main/java/org/jitsi/jicofo/conference/JitsiMeetConferenceImpl.java
index 4945163517..c010f4407d 100644
--- a/src/main/java/org/jitsi/jicofo/conference/JitsiMeetConferenceImpl.java
+++ b/src/main/java/org/jitsi/jicofo/conference/JitsiMeetConferenceImpl.java
@@ -445,7 +445,8 @@ private void joinTheRoom()
{
logger.info("Joining " + roomName);
- chatRoom = getClientXmppProvider().findOrCreateRoom(roomName);
+ ChatRoom chatRoom = getClientXmppProvider().findOrCreateRoom(roomName);
+ this.chatRoom = chatRoom;
chatRoom.addListener(chatRoomListener);
AuthenticationAuthority authenticationAuthority = jicofoServices.getAuthenticationAuthority();
@@ -465,6 +466,7 @@ else if (ConferenceConfig.config.enableAutoOwner())
JigasiConfig.config.xmppConnectionName()
),
this,
+ chatRoom,
jicofoServices.getXmppServices().getJigasiDetector(),
logger);
@@ -827,9 +829,9 @@ private void terminateParticipant(
synchronized (participantLock)
{
- if (participant.isSessionEstablished())
+ JingleSession jingleSession = participant.getJingleSession();
+ if (jingleSession != null)
{
- JingleSession jingleSession = participant.getJingleSession();
jingle.terminateSession(jingleSession, reason, message, sendSessionTerminate);
@@ -1720,6 +1722,7 @@ public void onInviteFailed(ParticipantInviteRunnable channelAllocator)
* {@inheritDoc}
*/
@Override
+ @Nullable
public ChatRoom getChatRoom()
{
return chatRoom;
diff --git a/src/main/java/org/jitsi/jicofo/conference/Participant.java b/src/main/java/org/jitsi/jicofo/conference/Participant.java
index 73e36702dd..0e16413681 100644
--- a/src/main/java/org/jitsi/jicofo/conference/Participant.java
+++ b/src/main/java/org/jitsi/jicofo/conference/Participant.java
@@ -418,15 +418,6 @@ public ConferenceSourceMap getSources()
return conference == null ? new ConferenceSourceMap() : conference.getSourcesForParticipant(this);
}
- /**
- * @return {@code true} if the Jingle session with this participant has
- * been established.
- */
- public boolean isSessionEstablished()
- {
- return jingleSession != null;
- }
-
/**
* Add a set of remote sources, which are to be signaled to the remote side. The sources may be signaled
* immediately, or queued to be signaled later.
@@ -440,7 +431,8 @@ public void addRemoteSources(ConferenceSourceMap sources)
sources = sources.copy().stripByMediaType(getSupportedMediaTypes());
}
- if (!isSessionEstablished())
+ JingleSession jingleSession = getJingleSession();
+ if (jingleSession == null)
{
logger.debug("No Jingle session yet, queueing source-add.");
remoteSourcesQueue.sourceAdd(sources);
@@ -467,7 +459,7 @@ public void addRemoteSources(ConferenceSourceMap sources)
}
jingle.sendAddSourceIQ(
sources,
- getJingleSession(),
+ jingleSession,
ConferenceConfig.config.getUseJsonEncodedSources() && supportsJsonEncodedSources());
}
}
@@ -527,7 +519,8 @@ public void removeRemoteSources(ConferenceSourceMap sources)
sources = sources.copy().stripByMediaType(getSupportedMediaTypes());
}
- if (!isSessionEstablished())
+ JingleSession jingleSession = getJingleSession();
+ if (jingleSession == null)
{
logger.debug("No Jingle session yet, queueing source-remove.");
remoteSourcesQueue.sourceRemove(sources);
@@ -554,7 +547,7 @@ public void removeRemoteSources(ConferenceSourceMap sources)
}
jingle.sendRemoveSourceIQ(
sources,
- getJingleSession(),
+ jingleSession,
ConferenceConfig.config.getUseJsonEncodedSources() && supportsJsonEncodedSources());
}
}
@@ -571,9 +564,10 @@ public void sendQueuedRemoteSources()
return;
}
- if (!isSessionEstablished())
+ JingleSession jingleSession = getJingleSession();
+ if (jingleSession == null)
{
- logger.warn("Can not singal remote sources, Jingle session not established.");
+ logger.warn("Can not signal remote sources, Jingle session not established.");
return;
}
diff --git a/src/main/java/org/jitsi/jicofo/jigasi/TranscriberManager.java b/src/main/java/org/jitsi/jicofo/jigasi/TranscriberManager.java
index b7b352eed0..24a7bf3750 100644
--- a/src/main/java/org/jitsi/jicofo/jigasi/TranscriberManager.java
+++ b/src/main/java/org/jitsi/jicofo/jigasi/TranscriberManager.java
@@ -93,6 +93,7 @@ public class TranscriberManager
*/
public TranscriberManager(@NotNull XmppProvider xmppProvider,
@NotNull JitsiMeetConferenceImpl conference,
+ @NotNull ChatRoom chatRoom,
JigasiDetector jigasiDetector,
@NotNull Logger parentLogger)
{
@@ -101,7 +102,7 @@ public TranscriberManager(@NotNull XmppProvider xmppProvider,
this.connection = xmppProvider.getXmppConnection();
this.conference = conference;
- this.chatRoom = conference.getChatRoom();
+ this.chatRoom = chatRoom;
chatRoom.addListener(chatRoomListener);
this.jigasiDetector = jigasiDetector;
}
diff --git a/src/main/kotlin/org/jitsi/jicofo/xmpp/AvModerationHandler.kt b/src/main/kotlin/org/jitsi/jicofo/xmpp/AvModerationHandler.kt
index c916164884..b35484f5cd 100644
--- a/src/main/kotlin/org/jitsi/jicofo/xmpp/AvModerationHandler.kt
+++ b/src/main/kotlin/org/jitsi/jicofo/xmpp/AvModerationHandler.kt
@@ -68,16 +68,17 @@ class AvModerationHandler(
if (incomingJson["type"] == "av_moderation") {
val conferenceJid = JidCreate.entityBareFrom(incomingJson["room"]?.toString())
- val conference = conferenceStore.getConference(conferenceJid) ?: return@execute Unit.also {
- logger.warn("Not processing message for not existing conference conferenceJid=$conferenceJid")
- }
+ val conference = conferenceStore.getConference(conferenceJid)
+ ?: throw IllegalStateException("Conference $conferenceJid does not exist.")
+ val chatRoom = conference.chatRoom
+ ?: throw IllegalStateException("Conference has no associated chatRoom.")
val enabled = incomingJson["enabled"] as Boolean?
if (enabled != null) {
val mediaType = MediaType.parseString(incomingJson["mediaType"] as String)
- val oldEnabledValue = conference.chatRoom.isAvModerationEnabled(mediaType)
- conference.chatRoom.setAvModerationEnabled(mediaType, enabled)
+ val oldEnabledValue = chatRoom.isAvModerationEnabled(mediaType)
+ chatRoom.setAvModerationEnabled(mediaType, enabled)
if (oldEnabledValue != enabled && enabled) {
logger.info(
"Moderation had been enabled for conferenceJid=$conferenceJid, by=${
@@ -88,14 +89,13 @@ class AvModerationHandler(
conference.muteAllParticipants(mediaType)
}
} else {
- val lists = incomingJson["whitelists"]?.let { parseAsMapOfStringToListOfString(it) }
- if (lists != null) {
- conference.chatRoom.updateAvModerationWhitelists(lists)
+ incomingJson["whitelists"]?.let {
+ chatRoom.updateAvModerationWhitelists(parseAsMapOfStringToListOfString(it))
}
}
}
} catch (e: Exception) {
- logger.warn("Cannot parse json for av_moderation coming from ${stanza.from}", e)
+ logger.warn("Failed to process av_moderation request from ${stanza.from}", e)
}
}
}
diff --git a/src/main/kotlin/org/jitsi/jicofo/xmpp/ConferenceIqHandler.kt b/src/main/kotlin/org/jitsi/jicofo/xmpp/ConferenceIqHandler.kt
index efd9666bd0..38ee1c2f0e 100644
--- a/src/main/kotlin/org/jitsi/jicofo/xmpp/ConferenceIqHandler.kt
+++ b/src/main/kotlin/org/jitsi/jicofo/xmpp/ConferenceIqHandler.kt
@@ -109,8 +109,6 @@ class ConferenceIqHandler(
* which should be returned to the user
*/
private fun processExtensions(query: ConferenceIq, response: ConferenceIq?, roomExists: Boolean): IQ? {
- val peerJid = query.from
- var identity: String? = null
val room = query.room
val isBreakoutRoom = breakoutAddress != null && room.domain == breakoutAddress
@@ -120,27 +118,20 @@ class ConferenceIqHandler(
val authErrorOrResponse = authAuthority.processAuthentication(query, response)
// Checks if authentication module wants to cancel further
- // processing and eventually returns it's response
+ // processing and eventually returns its response
if (authErrorOrResponse != null) {
return authErrorOrResponse
}
// Only authenticated users are allowed to create new rooms
if (!roomExists) {
- // If a breakout room exists and all members had left the main room, skip
+ // If an associated breakout room exists and all members have left the main room, skip
// authentication for the main room so users can go back to it.
- var breakoutRoomExists: Boolean = false
- for (conference in focusManager.getConferences()) {
- if (conference.chatRoom.isBreakoutRoom && room.toString() == conference.chatRoom.mainRoom) {
- breakoutRoomExists = true
- break
- }
+ val breakoutRoomExists = focusManager.conferences.any { conference ->
+ conference.chatRoom?.let { it.isBreakoutRoom && room.toString() == it.mainRoom } ?: false
}
- if (!breakoutRoomExists) {
- identity = authAuthority.getUserIdentity(peerJid)
- if (identity == null) {
- // Error not authorized
- return ErrorFactory.createNotAuthorizedError(query, "not authorized user domain")
- }
+ if (!breakoutRoomExists && authAuthority.getUserIdentity(query.from) == null) {
+ // Error not authorized
+ return ErrorFactory.createNotAuthorizedError(query, "not authorized user domain")
}
}
}