Skip to content

Commit

Permalink
fix: Fixes tests and improve check readability.
Browse files Browse the repository at this point in the history
  • Loading branch information
damencho committed Jan 7, 2021
1 parent dd5194c commit 929a439
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 45 deletions.
8 changes: 0 additions & 8 deletions pom.xml
Expand Up @@ -428,14 +428,6 @@
</properties>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<mainClass>org.jitsi.jicofo.Main</mainClass>
</configuration>
</plugin>
<plugin>
<!-- Instructs the plugin to add the current package version in the jar manifest
So we can access it runtime with: .class.getPackage().getImplementationVersion()
Expand Down
69 changes: 32 additions & 37 deletions src/main/java/org/jitsi/jigasi/JvbConference.java
Expand Up @@ -166,9 +166,9 @@ private static ExtensionElement addSupportedFeatures(
AbstractPacketExtension features = new AbstractPacketExtension(DiscoverInfo.NAMESPACE, "features"){};

meetTools.addSupportedFeature(SIP_GATEWAY_FEATURE_NAME);
features.addChildExtension(getFeature(SIP_GATEWAY_FEATURE_NAME));
features.addChildExtension(createFeature(SIP_GATEWAY_FEATURE_NAME));
meetTools.addSupportedFeature(DTMF_FEATURE_NAME);
features.addChildExtension(getFeature(DTMF_FEATURE_NAME));
features.addChildExtension(createFeature(DTMF_FEATURE_NAME));

ConfigurationService cfg
= JigasiBundleActivator.getConfigurationService();
Expand All @@ -193,12 +193,25 @@ private static ExtensionElement addSupportedFeatures(
if (JigasiBundleActivator.isSipStartMutedEnabled())
{
meetTools.addSupportedFeature(MUTED_FEATURE_NAME);
features.addChildExtension(getFeature(MUTED_FEATURE_NAME));
features.addChildExtension(createFeature(MUTED_FEATURE_NAME));
}

return features;
}

/**
* Creates a feature xmpp extension, that can be added to features and used in presence.
* @param var the value to be added.
* @return the extension element.
*/
private static ExtensionElement createFeature(String var)
{
AbstractPacketExtension feature = new AbstractPacketExtension(null, "feature"){};
feature.setAttribute("var", var);

return feature;
}

/**
* {@link AbstractGatewaySession} that uses this <tt>JvbConference</tt>
* instance.
Expand Down Expand Up @@ -1215,14 +1228,13 @@ else if(ChatRoomMemberPresenceChangeEvent.MEMBER_UPDATED
*/
private void processChatRoomMemberLeft(ChatRoomMember member)
{
if (!this.started || getConnection() == null || !getConnection().isConnected())
if (!this.started)
{
// we want to ignore the leave events when stopping the conference,
// or connection is missing or not connected
return;
}

// if it is the focus leaving and we are not in the middle of hangup
// we leave this here before checking connection to make tests happy
if (member.getName().equals(gatewaySession.getFocusResourceAddr()))
{
logger.info(this.callContext + " Focus left! - stopping the call");
Expand All @@ -1231,32 +1243,28 @@ private void processChatRoomMemberLeft(ChatRoomMember member)
return;
}

if (getConnection() == null || !getConnection().isConnected())
{
// we want to ignore the leave events when stopping the conference,
// or connection is missing or not connected
return;
}

// if lobby is not enabled or single moderator mode is detected
// there is nothing to process
// but otherwise we will check whether there are
// but otherwise we will check whether there are jigasi participants
// and jigasi cannot moderate those from lobby, we need to end the conference by all jigasi
// leaving it
if (this.lobbyEnabled && !this.singleModeratorEnabled)
{
boolean onlyJigasisInRoom = !this.mucRoom.getMembers().stream().anyMatch(m -> {
// If its us or jicofo ignore checking for jigasi
if (m.getName().equals(getResourceIdentifier().toString())
|| m.getName().equals(gatewaySession.getFocusResourceAddr()))
{
return false;
}

if (!jigasiChatRoomMembers.contains(m.getName()))
{
return true;
}

return false;
});
boolean onlyJigasisInRoom = this.mucRoom.getMembers().stream().allMatch(m ->
m.getName().equals(getResourceIdentifier().toString()) // ignore if it is us
|| m.getName().equals(gatewaySession.getFocusResourceAddr()) // ignore if it is jicofo
|| jigasiChatRoomMembers.contains(m.getName()));

if (onlyJigasisInRoom)
{
// there are only jigasi participants in the room with lobby enabled
// and jigasi cannot moderate those from lobby, we need to end the conference by all jigasi
// leaving it
logger.info(this.callContext + " Leaving room with lobby enabled and only jigasi participants!");

// let's play something
Expand Down Expand Up @@ -1882,19 +1890,6 @@ public void onPasswordReceived(String pwd)
joinConferenceRoom();
}

/**
* Creates a feature xmpp extension, that can be added to features and used in presence.
* @param var the value to be added.
* @return the extension element.
*/
private static ExtensionElement getFeature(String var)
{
AbstractPacketExtension feature = new AbstractPacketExtension(null, "feature"){};
feature.setAttribute("var", var);

return feature;
}

/**
* Changes the value of the flag whether lobby is enabled or not.
* @param value the new value.
Expand Down

0 comments on commit 929a439

Please sign in to comment.