Skip to content

Commit

Permalink
fixes igniterealtime#16: Ensure compatibility with Openfire 4.8
Browse files Browse the repository at this point in the history
In Openfire 4.8, API that was used by this plugin was removed. In this commit, usage of that API has been replaced.
  • Loading branch information
guusdk committed May 2, 2023
1 parent 1629ad2 commit b51e00e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
5 changes: 5 additions & 0 deletions changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ <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.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
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<description>Openfire plugin to save the user status to the database.</description>
<author>Stefan Reuter</author>
<version>${project.version}</version>
<date>10/29/2019</date>
<date>2023-05-02</date>
<minServerVersion>4.0.0</minServerVersion>
<minJavaVersion>1.8</minJavaVersion>
<databaseKey>user-status</databaseKey>
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.3-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 b51e00e

Please sign in to comment.