Save on bandwidth if the user wants to hide icon data

This commit is contained in:
2026-01-24 09:40:01 -07:00
parent 4411923b77
commit 27d5049261
2 changed files with 11 additions and 2 deletions

View File

@@ -465,6 +465,13 @@ app.get(
t.String(
t.String({ description: 'The IDs for the icons you want to get' })
)
),
data: t.Optional(
t.String({
description:
'If set to false, this will not include icon data, otherwise it will. Setting it to true would have the same result as not having it at all.',
examples: ['true', 'false']
})
)
})
}

View File

@@ -16,6 +16,7 @@ export async function handler (context: Context) {
const { connection: connection0, db: db0 } = dbInfo0
const { connection: connection1, db: db1 } = dbInfo1
let dataQuery = context.query.data
let uuidQuery = context.query.uuid
let idQuery = context.query.id ? parseInt(context.query.id, 10) : 0
let uuidsQuery = context.query.uuids
@@ -103,7 +104,8 @@ export async function handler (context: Context) {
const result = {
username: userData[0].username,
userId: icon[0].userId,
data: icon[0].data,
data:
dataQuery && dataQuery.toLowerCase() == 'false' ? null : icon[0].data,
hash: icon[0].hash,
id: icon[0].id,
price: icon[0].price,
@@ -144,7 +146,7 @@ export async function handler (context: Context) {
const result = icons.map(i => ({
username: usersMap[i.userId] ?? 'Unknown',
userId: i.userId,
data: i.data,
data: dataQuery && dataQuery.toLowerCase() == 'false' ? null : i.data,
id: i.id,
price: i.price,
buyable: i.state == 1,