Switch back to just using uuids for marketplace icons, can't convert properly
This commit is contained in:
@@ -448,19 +448,11 @@ app.get(
|
||||
tags: ['Berry Dash', 'Icon Marketplace']
|
||||
},
|
||||
query: t.Object({
|
||||
uuid: t.Optional(
|
||||
t.String({ description: 'The UUID for the icon you want to get' })
|
||||
),
|
||||
id: t.Optional(
|
||||
t.String(
|
||||
t.String({ description: 'The ID for the icon you want to get' })
|
||||
)
|
||||
),
|
||||
uuids: t.Optional(
|
||||
t.String(
|
||||
t.String({ description: 'The UUIDs for the icons you want to get' })
|
||||
)
|
||||
),
|
||||
ids: t.Optional(
|
||||
t.String(
|
||||
t.String({ description: 'The IDs for the icons you want to get' })
|
||||
|
||||
@@ -126,13 +126,16 @@ export const berryDashChatroomReports = mysqlTable('chatroom_reports', {
|
||||
})
|
||||
|
||||
export const berryDashMarketplaceIcons = mysqlTable('marketplaceicons', {
|
||||
id: bigint('id', { mode: 'number' }).primaryKey().autoincrement().notNull(),
|
||||
uuid: varchar('uuid', { length: 36 }).notNull(),
|
||||
id: varchar('id', { length: 36 }).notNull(),
|
||||
userId: bigint('userId', { mode: 'number' }).notNull(),
|
||||
data: longtext('data').notNull(),
|
||||
hash: varchar('hash', { length: 128 }).notNull(),
|
||||
timestamp: bigint('timestamp', { mode: 'number' }).notNull(),
|
||||
state: tinyint('state').default(0).notNull(),
|
||||
price: bigint('price', { mode: 'number' }).default(0).notNull(),
|
||||
name: text('name').notNull()
|
||||
name: text('name').notNull(),
|
||||
place: bigint('place', { mode: 'number' })
|
||||
.primaryKey()
|
||||
.autoincrement()
|
||||
.notNull()
|
||||
})
|
||||
|
||||
@@ -17,25 +17,22 @@ export async function handler (context: Context) {
|
||||
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
|
||||
let idsQuery = context.query.ids
|
||||
if (!uuidQuery && !idQuery && !uuidsQuery && !idsQuery) {
|
||||
let idQuery = context.query.id
|
||||
let idsQuery: string | string[] = context.query.ids
|
||||
if (!idQuery && !idsQuery) {
|
||||
connection0.end()
|
||||
connection1.end()
|
||||
return jsonResponse(
|
||||
{
|
||||
success: false,
|
||||
message: 'Must have either ID, UUID, IDS, or UUIDS in params',
|
||||
message: 'Must have UUID or UUIDS in params',
|
||||
data: null
|
||||
},
|
||||
400
|
||||
)
|
||||
}
|
||||
try {
|
||||
if (uuidsQuery) uuidsQuery = JSON.parse(uuidsQuery)
|
||||
if (idsQuery) idsQuery = JSON.parse(idsQuery)
|
||||
if (idsQuery) idsQuery = JSON.parse(idsQuery) as string[]
|
||||
} catch {
|
||||
connection0.end()
|
||||
connection1.end()
|
||||
@@ -49,7 +46,7 @@ export async function handler (context: Context) {
|
||||
)
|
||||
}
|
||||
|
||||
if (idQuery || uuidQuery) {
|
||||
if (idQuery) {
|
||||
const icon = await db1
|
||||
.select({
|
||||
id: berryDashMarketplaceIcons.id,
|
||||
@@ -62,11 +59,7 @@ export async function handler (context: Context) {
|
||||
name: berryDashMarketplaceIcons.name
|
||||
})
|
||||
.from(berryDashMarketplaceIcons)
|
||||
.where(
|
||||
!uuidQuery
|
||||
? eq(berryDashMarketplaceIcons.id, idQuery)
|
||||
: eq(berryDashMarketplaceIcons.uuid, uuidQuery)
|
||||
)
|
||||
.where(eq(berryDashMarketplaceIcons.id, idQuery))
|
||||
.limit(1)
|
||||
.execute()
|
||||
if (!icon[0]) {
|
||||
@@ -121,17 +114,7 @@ export async function handler (context: Context) {
|
||||
const icons = await db1
|
||||
.select()
|
||||
.from(berryDashMarketplaceIcons)
|
||||
.where(
|
||||
!uuidsQuery
|
||||
? inArray(
|
||||
berryDashMarketplaceIcons.id,
|
||||
idsQuery as unknown as number[]
|
||||
)
|
||||
: inArray(
|
||||
berryDashMarketplaceIcons.uuid,
|
||||
uuidsQuery as unknown as string[]
|
||||
)
|
||||
)
|
||||
.where(inArray(berryDashMarketplaceIcons.id, idsQuery as string[]))
|
||||
.execute()
|
||||
|
||||
const userIds = Array.from(new Set(icons.map(i => i.userId)))
|
||||
|
||||
@@ -109,10 +109,10 @@ export async function handler (context: Context) {
|
||||
} else if (body3.onlyShowValue === 1 && userId) {
|
||||
filters.push(sql`${berryDashMarketplaceIcons.userId} != ${userId}`)
|
||||
} else if (body3.onlyShowValue === 2) {
|
||||
filters.push(inArray(berryDashMarketplaceIcons.uuid, body3.currentIcons))
|
||||
filters.push(inArray(berryDashMarketplaceIcons.id, body3.currentIcons))
|
||||
} else if (body3.onlyShowValue === 3) {
|
||||
filters.push(
|
||||
not(inArray(berryDashMarketplaceIcons.uuid, body3.currentIcons))
|
||||
not(inArray(berryDashMarketplaceIcons.id, body3.currentIcons))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,10 +172,10 @@ export async function handler (context: Context) {
|
||||
)
|
||||
|
||||
const hashResult = hash(atob(body.fileContent), 'sha512')
|
||||
const uuid = crypto.randomUUID()
|
||||
const id = crypto.randomUUID()
|
||||
|
||||
await db1.insert(berryDashMarketplaceIcons).values({
|
||||
uuid,
|
||||
id,
|
||||
userId,
|
||||
data: body.fileContent,
|
||||
hash: hashResult,
|
||||
|
||||
Reference in New Issue
Block a user