Add getSkins and getCapes methods to user modules
Introduces getSkins and getCapes functions in both userRepository and userService to retrieve player skins and capes from the database. These methods return structured data for use in higher-level application logic.
This commit is contained in:
@@ -13,6 +13,46 @@ const generateKeyPairAsync = util.promisify(crypto.generateKeyPair)
|
||||
const TEMP_DIR = path.join(process.cwd(), "data", "temp")
|
||||
const TEXTURES_DIR = path.join(process.cwd(), "data", "textures")
|
||||
|
||||
async function getSkins(uuid) {
|
||||
try {
|
||||
const rawSkins = await userRepository.getSkins(uuid)
|
||||
|
||||
return {
|
||||
code: 200,
|
||||
data: {
|
||||
skins: rawSkins.map(r => ({
|
||||
id: r.hash,
|
||||
state: r.active === 1 ? "ACTIVE" : "INACTIVE",
|
||||
url: r.url,
|
||||
variant: r.variant || "CLASSIC"
|
||||
}))
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
async function getCapes(uuid) {
|
||||
try {
|
||||
const rawCapes = await userRepository.getCapes(uuid)
|
||||
|
||||
return {
|
||||
code: 200,
|
||||
data: {
|
||||
capes: rawCapes.map(r => ({
|
||||
id: r.hash,
|
||||
state: r.active === 1 ? "ACTIVE" : "INACTIVE",
|
||||
url: r.url,
|
||||
alias: r.alias || "LentiaCustomCape"
|
||||
}))
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
async function getPlayerProperties(uuid) {
|
||||
try {
|
||||
const result = await userRepository.getPlayerProperties(uuid)
|
||||
@@ -529,8 +569,10 @@ async function removeCape(uuid, hash) {
|
||||
|
||||
module.exports = {
|
||||
banUser,
|
||||
getCapes,
|
||||
showCape,
|
||||
hideCape,
|
||||
getSkins,
|
||||
unbanUser,
|
||||
resetSkin,
|
||||
isBlocked,
|
||||
|
||||
Reference in New Issue
Block a user