Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #34: Openfire 4.8.0 compatibility #36

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>plugins</artifactId>
<groupId>org.igniterealtime.openfire</groupId>
<version>4.6.4</version>
<version>4.7.5</version>
</parent>

<groupId>org.igniterealtime.openfire.plugins</groupId>
Expand Down
1 change: 1 addition & 0 deletions src/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ <h1>
<p><b>1.0.0</b> -- (tbd)</p>
<ul>
<li>New minimum server requirement: 4.8.0</li>
<li><a href="https://github.com/igniterealtime/openfire-pushnotification-plugin/issues/34">Issue 34</a>: Replaced all usage of code removed or deprecated in Openfire 4.8.0</li>
</ul>

<p><b>0.9.3</b> -- August 31, 2023</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 Ignite Realtime Foundation. All rights reserved.
* Copyright (C) 2019-2023 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 Down Expand Up @@ -105,7 +105,7 @@ public IQ handleIQ( final IQ packet ) throws UnauthorizedException
return result;
}

if ( !XMPPServer.getInstance().getUserManager().isRegisteredUser( packet.getFrom() ) )
if ( !XMPPServer.getInstance().getUserManager().isRegisteredUser( packet.getFrom(), false ) )
{
Log.info( "Denying service for an entity that's not recognized as a registered user: {}", packet.getFrom() );
throw new UnauthorizedException( "This service is only available to registered, local users." );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 Ignite Realtime Foundation. All rights reserved.
* Copyright (C) 2019-2023 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 @@ -26,7 +26,6 @@
import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.openfire.user.User;
import org.jivesoftware.openfire.user.UserNotFoundException;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.SystemProperty;
import org.jivesoftware.util.cache.Cache;
import org.jivesoftware.util.cache.CacheFactory;
Expand Down Expand Up @@ -197,7 +196,7 @@ private void tryPushNotification( User user, Message message )
}

// Basic throttling.
final Lock lock = CacheFactory.getLock(user.getUsername(), MESSAGES_BY_USER);
final Lock lock = MESSAGES_BY_USER.getLock(user.getUsername());
lock.lock();
try {
if ( wasPushAttemptedFor( user, message, Duration.ofMinutes(5)) ) {
Expand Down Expand Up @@ -326,7 +325,7 @@ public boolean wasPushAttemptedFor( final User user, final Message message, fina
{
final String identifier = getMessageIdentifier(user, message);

final Lock lock = CacheFactory.getLock(user.getUsername(), MESSAGES_BY_USER);
final Lock lock = MESSAGES_BY_USER.getLock(user.getUsername());
lock.lock();
try {
/* This can be short-circuited, as the same identifier is used in the secondary cache.
Expand Down Expand Up @@ -359,7 +358,7 @@ public boolean wasPushAttemptedFor( final User user, final Message message, fina
*/
public long attemptsForLast( final User user, final Duration duration )
{
final Lock lock = CacheFactory.getLock(user.getUsername(), MESSAGES_BY_USER);
final Lock lock = MESSAGES_BY_USER.getLock(user.getUsername());
lock.lock();
try {
final HashSet<String> messageIdentifiers = MESSAGES_BY_USER.get(user.getUsername());
Expand Down Expand Up @@ -390,7 +389,7 @@ public void addAttemptFor( final User user, final Message message )
{
final String identifier = getMessageIdentifier(user, message);

final Lock lock = CacheFactory.getLock(user.getUsername(), MESSAGES_BY_USER);
final Lock lock = MESSAGES_BY_USER.getLock(user.getUsername());
lock.lock();
try {
HashSet<String> messageIdentifiers = MESSAGES_BY_USER.get(user.getUsername());
Expand Down Expand Up @@ -426,7 +425,7 @@ public void purgeAllOlderThan(final Instant cutoff)
// Iterate over all message identifiers for each user, to be able to apply the required user-specific lock.
for ( final String username : userNames )
{
final Lock lock = CacheFactory.getLock(username, MESSAGES_BY_USER);
final Lock lock = MESSAGES_BY_USER.getLock(username);
lock.lock();
try
{
Expand Down