Skip to content

Conversation

@ammodev
Copy link
Contributor

@ammodev ammodev commented Aug 10, 2025

No description provided.

@ammodev ammodev requested review from Copilot and twisti-dev August 10, 2025 19:50
@ammodev ammodev merged commit 3436338 into feat/cloud Aug 10, 2025
1 check passed
@ammodev ammodev deleted the feat/new-account branch August 10, 2025 19:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a comprehensive account system for the transaction API, refactoring the codebase from a user-based to an account-based transaction model. It introduces multi-account support per user, adds database migrations for the new account structure, and reorganizes networking packets.

Key changes:

  • Introduces account-based transactions replacing user-based transactions
  • Adds multi-account support with default account functionality
  • Implements database migrations to support the new account structure

Reviewed Changes

Copilot reviewed 91 out of 93 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
surf-transaction-api/src/main/kotlin/dev/slne/surf/transaction/api/account/*.kt New account API interfaces, data classes, and serialization components
surf-transaction-api/src/main/kotlin/dev/slne/surf/transaction/api/user/TransactionUser.kt Refactored user interface to work with accounts
surf-transaction-server/src/main/kotlin/dev/slne/surf/transaction/server/account/*.kt Server-side account management implementation
surf-transaction-server/src/main/resources/db/migration/*.sql Database migrations for account tables and foreign key constraints
surf-transaction-core/.../netty/packets/ Reorganized and updated network packets for account-based operations
surf-transaction-paper/src/main/kotlin/.../commands/account/*.kt New account management commands for Paper plugin

* @return The [AccountEntity] if found, or null if not found.
*/
suspend fun fetchByAccountName(name: String): AccountEntity? =
AccountEntity.find { AccountTable.name like name }.singleOrNull()
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 'like' operator for exact name matching is incorrect and could lead to unintended matches. Use 'eq' operator instead for exact string comparison.

Suggested change
AccountEntity.find { AccountTable.name like name }.singleOrNull()
AccountEntity.find { AccountTable.name eq name }.singleOrNull()

Copilot uses AI. Check for mistakes.
): BigDecimal {
val account = accountRepository.fetchByAccountId(accountId)

return TransactionTable
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function returns before executing the query. The return statement should be after the query execution block, not before it.

Copilot uses AI. Check for mistakes.
this.accountId = UUID.randomUUID()
this.name = name
this.defaultAccount = defaultAccount
}.toApi()
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an account with the same name already exists, this logic sets it as default without clearing the previous default account, potentially creating multiple default accounts.

Suggested change
}.toApi()
val accountByName = fetchByAccountName(name)
if (accountByName != null) {
if (defaultAccount) {
clearDefaultAccountForOwner(owner, exceptAccountId = accountByName.accountId)
accountByName.defaultAccount = true
}
return accountByName.toApi()
}
val newAccount = AccountEntity.new {
this.owner = owner.uuid
this.accountId = UUID.randomUUID()
this.name = name
this.defaultAccount = defaultAccount
}
if (defaultAccount) {
clearDefaultAccountForOwner(owner, exceptAccountId = newAccount.accountId)
}
return newAccount.toApi()

Copilot uses AI. Check for mistakes.
identifier = identifier,
senderUuid = sender,
receiverUuid = receiver,
initiator = initiator?.toOfflineCloudPlayer(),
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property 'initiator' is already of type UUID?, but toOfflineCloudPlayer() is being called on it, which should be called on the UUID value directly.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants