mirror of
https://github.com/Qortal/qortal.git
synced 2025-07-23 04:36:50 +00:00
Fixed group ban expiry.
This commit is contained in:
@@ -131,7 +131,14 @@ public interface GroupRepository {
|
||||
|
||||
public GroupBanData getBan(int groupId, String member) throws DataException;
|
||||
|
||||
public boolean banExists(int groupId, String offender) throws DataException;
|
||||
/**
|
||||
* IMPORTANT: when using banExists() as part of validation, the timestamp must be that of the transaction that
|
||||
* is calling banExists() as part of its validation. It must NOT be the current time, unless this is being
|
||||
* called outside of validation, as part of an on demand check for a ban existing (such as via an API call).
|
||||
* This is because we need to evaluate a ban's status based on the time of the subsequent transaction, as
|
||||
* validation will not occur at a fixed time for every node. For some, it could be months into the future.
|
||||
*/
|
||||
public boolean banExists(int groupId, String offender, long timestamp) throws DataException;
|
||||
|
||||
public List<GroupBanData> getGroupBans(int groupId, Integer limit, Integer offset, Boolean reverse) throws DataException;
|
||||
|
||||
|
@@ -777,9 +777,9 @@ public class HSQLDBGroupRepository implements GroupRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean banExists(int groupId, String offender) throws DataException {
|
||||
public boolean banExists(int groupId, String offender, long timestamp) throws DataException {
|
||||
try {
|
||||
return this.repository.exists("GroupBans", "group_id = ? AND offender = ?", groupId, offender);
|
||||
return this.repository.exists("GroupBans", "group_id = ? AND offender = ? AND (expires_when IS NULL OR expires_when > ?)", groupId, offender, timestamp);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to check for group ban in repository", e);
|
||||
}
|
||||
|
@@ -73,7 +73,7 @@ public class CancelGroupBanTransaction extends Transaction {
|
||||
Account member = getMember();
|
||||
|
||||
// Check ban actually exists
|
||||
if (!this.repository.getGroupRepository().banExists(groupId, member.getAddress()))
|
||||
if (!this.repository.getGroupRepository().banExists(groupId, member.getAddress(), this.groupUnbanTransactionData.getTimestamp()))
|
||||
return ValidationResult.BAN_UNKNOWN;
|
||||
|
||||
// Check admin has enough funds
|
||||
|
@@ -78,7 +78,7 @@ public class GroupInviteTransaction extends Transaction {
|
||||
return ValidationResult.ALREADY_GROUP_MEMBER;
|
||||
|
||||
// Check invitee is not banned
|
||||
if (this.repository.getGroupRepository().banExists(groupId, invitee.getAddress()))
|
||||
if (this.repository.getGroupRepository().banExists(groupId, invitee.getAddress(), this.groupInviteTransactionData.getTimestamp()))
|
||||
return ValidationResult.BANNED_FROM_GROUP;
|
||||
|
||||
// Check creator has enough funds
|
||||
|
@@ -53,7 +53,7 @@ public class JoinGroupTransaction extends Transaction {
|
||||
return ValidationResult.ALREADY_GROUP_MEMBER;
|
||||
|
||||
// Check member is not banned
|
||||
if (this.repository.getGroupRepository().banExists(groupId, joiner.getAddress()))
|
||||
if (this.repository.getGroupRepository().banExists(groupId, joiner.getAddress(), this.joinGroupTransactionData.getTimestamp()))
|
||||
return ValidationResult.BANNED_FROM_GROUP;
|
||||
|
||||
// Check join request doesn't already exist
|
||||
|
@@ -103,7 +103,7 @@ public class UpdateGroupTransaction extends Transaction {
|
||||
Account newOwner = getNewOwner();
|
||||
|
||||
// Check new owner is not banned
|
||||
if (this.repository.getGroupRepository().banExists(this.updateGroupTransactionData.getGroupId(), newOwner.getAddress()))
|
||||
if (this.repository.getGroupRepository().banExists(this.updateGroupTransactionData.getGroupId(), newOwner.getAddress(), this.updateGroupTransactionData.getTimestamp()))
|
||||
return ValidationResult.BANNED_FROM_GROUP;
|
||||
|
||||
return ValidationResult.OK;
|
||||
|
Reference in New Issue
Block a user