Skip to content

Commit

Permalink
feat(server/accounts): attach ownerName to character accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Jul 30, 2024
1 parent a420f30 commit 761e94b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions server/accounts/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ const safeRemoveBalance = `${removeBalance} AND (balance - ?) >= 0`;
const addTransaction = `INSERT INTO accounts_transactions (actorId, fromId, toId, amount, message, note, fromBalance, toBalance) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`;
const getBalance = `SELECT balance FROM accounts WHERE id = ?`;
const doesAccountExist = `SELECT 1 FROM accounts WHERE id = ?`;
const getCharacterAccounts = `SELECT ac.role, a.* FROM \`accounts_access\` ac LEFT JOIN accounts a ON a.id = ac.accountId WHERE ac.charId = ?`;
const getOwnedCharacterAccounts = `${getCharacterAccounts} AND ac.role = 'owner'`;
const getCharacterAccounts = `SELECT access.role, account.*, CONCAT(c.firstName, " ", c.lastName) as ownerName
FROM \`accounts_access\` access
LEFT JOIN accounts account ON account.id = access.accountId
LEFT JOIN characters c ON account.owner = c.charId
WHERE access.charId = ?`;
const getOwnedCharacterAccounts = `${getCharacterAccounts} AND access.role = 'owner'`;

async function GenerateAccountId(conn: Connection) {
const date = new Date();
Expand Down
2 changes: 1 addition & 1 deletion types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export interface OxAccount {
owner?: number;
group?: string;
type: 'personal' | 'shared' | 'group';
role: 'contributor' | 'manager' | 'owner';
role: OxAccountRoles;
}

export interface DbGroup {
Expand Down

0 comments on commit 761e94b

Please sign in to comment.