mirror of
https://github.com/Qortal/qortal.git
synced 2025-07-22 20:26:50 +00:00
Fix some minor group-related bugs
Incorrect column names when saving a group ban. Missing column in LeaveGroupTransactions. More stringent validity checks in group-kick, group-ban and remove-group-admin. Added loads more tests to cover group actions.
This commit is contained in:
@@ -530,7 +530,7 @@ public class HSQLDBDatabaseUpdates {
|
||||
|
||||
// Leave group
|
||||
stmt.execute("CREATE TABLE LeaveGroupTransactions (signature Signature, leaver QortalPublicKey NOT NULL, group_id GroupID NOT NULL, "
|
||||
+ "member_reference Signature, admin_reference Signature, " + TRANSACTION_KEYS + ")");
|
||||
+ "member_reference Signature, admin_reference Signature, previous_group_id GroupID, " + TRANSACTION_KEYS + ")");
|
||||
|
||||
// Kick from group
|
||||
stmt.execute("CREATE TABLE GroupKickTransactions (signature Signature, admin QortalPublicKey NOT NULL, "
|
||||
@@ -618,6 +618,11 @@ public class HSQLDBDatabaseUpdates {
|
||||
stmt.execute("CREATE TABLE PublicizeTransactions (signature Signature, nonce INT NOT NULL, " + TRANSACTION_KEYS + ")");
|
||||
break;
|
||||
|
||||
case 20:
|
||||
// XXX Bug-fix, but remove when we build new genesis
|
||||
stmt.execute("ALTER TABLE LeaveGroupTransactions ADD COLUMN IF NOT EXISTS previous_group_id GroupID");
|
||||
break;
|
||||
|
||||
default:
|
||||
// nothing to do
|
||||
return false;
|
||||
|
@@ -828,7 +828,7 @@ public class HSQLDBGroupRepository implements GroupRepository {
|
||||
HSQLDBSaver saveHelper = new HSQLDBSaver("GroupBans");
|
||||
|
||||
saveHelper.bind("group_id", groupBanData.getGroupId()).bind("offender", groupBanData.getOffender()).bind("admin", groupBanData.getAdmin())
|
||||
.bind("banned", groupBanData.getBanned()).bind("reason", groupBanData.getReason()).bind("expiry", groupBanData.getExpiry())
|
||||
.bind("banned_when", groupBanData.getBanned()).bind("reason", groupBanData.getReason()).bind("expires_when", groupBanData.getExpiry())
|
||||
.bind("reference", groupBanData.getReference());
|
||||
|
||||
try {
|
||||
|
@@ -72,7 +72,11 @@ public class GroupBanTransaction extends Transaction {
|
||||
|
||||
Account offender = getOffender();
|
||||
|
||||
// Can't ban another admin unless the group owner
|
||||
// Can't ban group owner
|
||||
if (offender.getAddress().equals(groupData.getOwner()))
|
||||
return ValidationResult.INVALID_GROUP_OWNER;
|
||||
|
||||
// Can't ban another admin unless admin is the group owner
|
||||
if (!admin.getAddress().equals(groupData.getOwner()) && this.repository.getGroupRepository().adminExists(groupId, offender.getAddress()))
|
||||
return ValidationResult.INVALID_GROUP_OWNER;
|
||||
|
||||
|
@@ -74,7 +74,11 @@ public class GroupKickTransaction extends Transaction {
|
||||
if (!groupRepository.joinRequestExists(groupId, member.getAddress()) && !groupRepository.memberExists(groupId, member.getAddress()))
|
||||
return ValidationResult.NOT_GROUP_MEMBER;
|
||||
|
||||
// Can't kick another admin unless the group owner
|
||||
// Can't kick group owner
|
||||
if (member.getAddress().equals(groupData.getOwner()))
|
||||
return ValidationResult.INVALID_GROUP_OWNER;
|
||||
|
||||
// Can't kick another admin unless kicker is the group owner
|
||||
if (!admin.getAddress().equals(groupData.getOwner()) && groupRepository.adminExists(groupId, member.getAddress()))
|
||||
return ValidationResult.INVALID_GROUP_OWNER;
|
||||
|
||||
|
@@ -76,6 +76,10 @@ public class RemoveGroupAdminTransaction extends Transaction {
|
||||
if (!this.repository.getGroupRepository().adminExists(groupId, admin.getAddress()))
|
||||
return ValidationResult.NOT_GROUP_ADMIN;
|
||||
|
||||
// Check admin is not group owner
|
||||
if (admin.getAddress().equals(groupData.getOwner()))
|
||||
return ValidationResult.INVALID_GROUP_OWNER;
|
||||
|
||||
// Check creator has enough funds
|
||||
if (owner.getConfirmedBalance(Asset.QORT) < this.removeGroupAdminTransactionData.getFee())
|
||||
return ValidationResult.NO_BALANCE;
|
||||
|
Reference in New Issue
Block a user