Skip to content

Commit

Permalink
Openfire 4.10.0 compatibility
Browse files Browse the repository at this point in the history
Fixes compatibility issue with Openfire 4.10.0. This plugin now requires 4.10.0 (it is not compatible with earlier versions of Openfire).

The build depends on a snapshot build of 4.10.0, which isn't ideal. At the time of writing, there's no stable release of that version yet.

fixes #392
  • Loading branch information
guusdk committed Oct 30, 2024
1 parent 68bc682 commit 6a6c64e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
6 changes: 6 additions & 0 deletions changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ <h1>
Monitoring Plugin Changelog
</h1>

<p><b>2.7.0</b> -- (To be determined)</p>
<ul>
<li>Requires Openfire 4.10.0</li>
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/392'>Issue #392</a>] - Fixes: Compatibility issue with Openfire 4.10.0</li>
</ul>

<p><b>2.6.1</b> -- (To be determined)</p>
<ul>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<description>Monitors conversations and statistics of the server.</description>
<author>Ignite Realtime</author>
<version>${project.version}</version>
<date>2024-09-12</date>
<minServerVersion>4.8.0</minServerVersion>
<date>2024-10-30</date>
<minServerVersion>4.10.0</minServerVersion>
<databaseKey>monitoring</databaseKey>
<databaseVersion>8</databaseVersion>

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<parent>
<artifactId>plugins</artifactId>
<groupId>org.igniterealtime.openfire</groupId>
<version>4.8.0</version>
<version>4.10.0-SNAPSHOT</version>
</parent>
<groupId>org.igniterealtime.openfire.plugins</groupId>
<artifactId>monitoring</artifactId>
<version>2.6.1-SNAPSHOT</version>
<version>2.7.0-SNAPSHOT</version>
<name>Monitoring Plugin</name>
<description>Monitors conversations and statistics of the server.</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.disco.ServerFeaturesProvider;
import org.jivesoftware.openfire.forward.Forwarded;
import org.jivesoftware.openfire.muc.MUCRole;
import org.jivesoftware.openfire.muc.MUCRoom;
import org.jivesoftware.openfire.muc.MultiUserChatService;
import org.jivesoftware.openfire.muc.*;
import org.jivesoftware.openfire.plugin.MonitoringPlugin;
import org.jivesoftware.util.NamedThreadFactory;
import org.jivesoftware.util.NotFoundException;
Expand Down Expand Up @@ -178,12 +176,12 @@ public IQ handleIQ( final IQ packet ) throws UnauthorizedException {
if (service.isSysadmin(requestor)) {
pass = true;
}
MUCRole.Affiliation aff = room.getAffiliation(requestor);
if (aff != MUCRole.Affiliation.outcast) {
if (aff == MUCRole.Affiliation.owner || aff == MUCRole.Affiliation.admin) {
final Affiliation aff = room.getAffiliation(requestor);
if (aff != Affiliation.outcast) {
if (aff == Affiliation.owner || aff == Affiliation.admin) {
pass = true;
} else if (room.isMembersOnly()) {
if (aff == MUCRole.Affiliation.member) {
if (aff == Affiliation.member) {
pass = true;
}
} else {
Expand All @@ -197,7 +195,7 @@ public IQ handleIQ( final IQ packet ) throws UnauthorizedException {

// Filtering by JID should only be available to entities that would already have been allowed to know the publisher
// of the events (e.g. this could not be used by a visitor to a semi-anonymous MUC).
final MUCRole occupant = room.getOccupantByFullJID(packet.getFrom());
final MUCOccupant occupant = room.getOccupantByFullJID(packet.getFrom());
if ( !room.canAnyoneDiscoverJID() ) {
final FormField withValue = queryRequest.getDataForm().getField("with");
if ( withValue != null && withValue.getFirstValue() != null && !withValue.getFirstValue().isEmpty() ) {
Expand All @@ -208,8 +206,8 @@ public IQ handleIQ( final IQ packet ) throws UnauthorizedException {
return buildErrorResponse(packet, PacketError.Condition.bad_request, "The value of the 'with' field must be a valid JID (but is not).");
}

// Unless the requestor is a moderator, or is filtering by it's own JID, disallow the request.
final boolean isModerator = occupant != null && occupant.getRole() == MUCRole.Role.moderator;
// Unless the requestor is a moderator, or is filtering by its own JID, disallow the request.
final boolean isModerator = occupant != null && occupant.getRole() == Role.moderator;
final boolean isFilteringByOwnJid = with.asBareJID().equals( packet.getFrom().asBareJID() );
if ( !isModerator && !isFilteringByOwnJid ) {
Log.debug("Unable to process query as requestor '{}' is not a moderator of the MUC room '{}', and is filtering by JID '{}' which is not its own.", requestor, archiveJid, with);
Expand Down
10 changes: 5 additions & 5 deletions src/java/org/jivesoftware/openfire/archive/ConversationDAO.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Ignite Realtime Foundation. All rights reserved.
* Copyright (C) 2021-2024 Ignite Realtime Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,7 @@
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.database.SequenceManager;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.muc.MUCRole;
import org.jivesoftware.openfire.muc.MUCOccupant;
import org.jivesoftware.openfire.muc.MUCRoom;
import org.jivesoftware.openfire.user.UserNameManager;
import org.jivesoftware.openfire.user.UserNotFoundException;
Expand Down Expand Up @@ -110,10 +110,10 @@ public static Conversation createConversation(ConversationManager conversationMa
// Add list of existing room occupants as participants of this conversation
MUCRoom mucRoom = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(room).getChatRoom(room.getNode());
if (mucRoom != null) {
for (MUCRole role : mucRoom.getOccupants()) {
for (final MUCOccupant occupant : mucRoom.getOccupants()) {
UserParticipations userParticipations = new UserParticipations(true);
userParticipations.addParticipation(new ConversationParticipation(startDate, role.getNickname()));
participants.put(role.getUserAddress().toString(), userParticipations);
userParticipations.addParticipation(new ConversationParticipation(startDate, occupant.getNickname()));
participants.put(occupant.getUserAddress().toString(), userParticipations);
}
}

Expand Down

0 comments on commit 6a6c64e

Please sign in to comment.