Skip to content

Commit

Permalink
Merge pull request #17 from guusdk/16_OF4.8-compat
Browse files Browse the repository at this point in the history
fixes #16: Ensure compatibility with Openfire 4.8
  • Loading branch information
akrherz committed Nov 27, 2023
2 parents 0d4b9d4 + 1187539 commit 39768fe
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
6 changes: 6 additions & 0 deletions changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,16 @@ <h1>User Status Plugin Changelog</h1>
</div>

<div id="pageBody">
<h2>1.3.0 -- <span style="font-weight: normal;">(tbd)</span></h2>
<ul>
<li>[<a href='https://github.com/igniterealtime/openfire-userStatus-plugin/issues/16'>Issue #16</a>] - Ensure compatibility with Openfire 4.8 and later.</li>
</ul>

<h2>1.2.3 -- <span style="font-weight: normal;">May 2, 2023</span></h2>
<ul>
<li>Set max supported Openfire version to 4.8.0</li>
</ul>

<h2>1.2.2 -- <span style="font-weight: normal;">October 29, 2019</span></h2>
<ul>
<li>[<a href='https://github.com/igniterealtime/openfire-userStatus-plugin/issues/9'>Issue #9</a>] - HSQLDB upgrade script fails</li>
Expand Down
1 change: 0 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<version>${project.version}</version>
<date>2023-05-02</date>
<minServerVersion>4.0.0</minServerVersion>
<priorToServerVersion>4.8.0</priorToServerVersion>
<minJavaVersion>1.8</minJavaVersion>
<databaseKey>user-status</databaseKey>
<databaseVersion>1</databaseVersion>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</parent>
<groupId>org.igniterealtime.openfire.plugins</groupId>
<artifactId>userstatus</artifactId>
<version>1.2.4-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<name>UserStatus Plugin</name>
<description>Openfire plugin to save the user status to the database</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.openfire.user.PresenceEventDispatcher;
import org.jivesoftware.openfire.user.PresenceEventListener;
import org.jivesoftware.openfire.user.UserNotFoundException;
import org.jivesoftware.util.*;
import org.xmpp.packet.Presence;
import org.xmpp.packet.JID;
Expand Down Expand Up @@ -68,9 +69,26 @@ public void destroyPlugin()
SessionEventDispatcher.removeListener(this);
}

public static boolean isRegisteredLocalUser(JID user) {
if (XMPPServer.getInstance().isLocal(user)) {
try {
XMPPServer.getInstance().getUserManager().getUser(user.getNode());
return true;
}
catch (final UserNotFoundException e) {
return false;
}
}
return false;
}

public void sessionCreated(Session session)
{
if (!XMPPServer.getInstance().getUserManager().isRegisteredUser(session.getAddress()))
if (!isRegisteredLocalUser(session.getAddress())) {
return;
}

if (!isRegisteredLocalUser(session.getAddress()))
{
return;
}
Expand All @@ -80,7 +98,7 @@ public void sessionCreated(Session session)

public void sessionDestroyed(Session session)
{
if (!XMPPServer.getInstance().getUserManager().isRegisteredUser(session.getAddress()))
if (!isRegisteredLocalUser(session.getAddress()))
{
return;
}
Expand Down Expand Up @@ -178,7 +196,7 @@ private void updatePresence(ClientSession session, Presence presence)
PreparedStatement pstmt = null;
final String presenceText;

if (!XMPPServer.getInstance().getUserManager().isRegisteredUser(session.getAddress()))
if (!isRegisteredLocalUser(session.getAddress()))
{
return;
}
Expand Down

0 comments on commit 39768fe

Please sign in to comment.