Switch back to just using uuids for marketplace icons, can't convert properly
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
-- https://www.phpmyadmin.net/
|
-- https://www.phpmyadmin.net/
|
||||||
--
|
--
|
||||||
-- Host: localhost
|
-- Host: localhost
|
||||||
-- Generation Time: Jan 23, 2026 at 07:23 AM
|
-- Generation Time: Jan 24, 2026 at 08:31 PM
|
||||||
-- Server version: 12.1.2-MariaDB
|
-- Server version: 12.1.2-MariaDB
|
||||||
-- PHP Version: 8.5.2
|
-- PHP Version: 8.5.2
|
||||||
|
|
||||||
@@ -56,15 +56,15 @@ CREATE TABLE `chats` (
|
|||||||
--
|
--
|
||||||
|
|
||||||
CREATE TABLE `marketplaceicons` (
|
CREATE TABLE `marketplaceicons` (
|
||||||
`id` bigint(20) NOT NULL,
|
`id` varchar(36) NOT NULL,
|
||||||
`uuid` varchar(36) NOT NULL,
|
|
||||||
`userId` bigint(20) NOT NULL,
|
`userId` bigint(20) NOT NULL,
|
||||||
`data` mediumtext NOT NULL,
|
`data` mediumtext NOT NULL,
|
||||||
`hash` varchar(128) NOT NULL,
|
`hash` varchar(128) NOT NULL,
|
||||||
`timestamp` bigint(20) NOT NULL,
|
`timestamp` bigint(20) NOT NULL,
|
||||||
`state` tinyint(1) NOT NULL DEFAULT 0,
|
`state` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
`price` bigint(20) NOT NULL DEFAULT 0,
|
`price` bigint(20) NOT NULL DEFAULT 0,
|
||||||
`name` text NOT NULL
|
`name` text NOT NULL,
|
||||||
|
`place` bigint(20) NOT NULL
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPRESSED;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPRESSED;
|
||||||
|
|
||||||
-- --------------------------------------------------------
|
-- --------------------------------------------------------
|
||||||
@@ -116,7 +116,7 @@ ALTER TABLE `chats`
|
|||||||
-- Indexes for table `marketplaceicons`
|
-- Indexes for table `marketplaceicons`
|
||||||
--
|
--
|
||||||
ALTER TABLE `marketplaceicons`
|
ALTER TABLE `marketplaceicons`
|
||||||
ADD PRIMARY KEY (`id`);
|
ADD PRIMARY KEY (`place`);
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Indexes for table `userdata`
|
-- Indexes for table `userdata`
|
||||||
@@ -150,7 +150,7 @@ ALTER TABLE `chats`
|
|||||||
-- AUTO_INCREMENT for table `marketplaceicons`
|
-- AUTO_INCREMENT for table `marketplaceicons`
|
||||||
--
|
--
|
||||||
ALTER TABLE `marketplaceicons`
|
ALTER TABLE `marketplaceicons`
|
||||||
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;
|
MODIFY `place` bigint(20) NOT NULL AUTO_INCREMENT;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- AUTO_INCREMENT for table `userdata`
|
-- AUTO_INCREMENT for table `userdata`
|
||||||
|
|||||||
@@ -448,19 +448,11 @@ app.get(
|
|||||||
tags: ['Berry Dash', 'Icon Marketplace']
|
tags: ['Berry Dash', 'Icon Marketplace']
|
||||||
},
|
},
|
||||||
query: t.Object({
|
query: t.Object({
|
||||||
uuid: t.Optional(
|
|
||||||
t.String({ description: 'The UUID for the icon you want to get' })
|
|
||||||
),
|
|
||||||
id: t.Optional(
|
id: t.Optional(
|
||||||
t.String(
|
t.String(
|
||||||
t.String({ description: 'The ID for the icon you want to get' })
|
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(
|
ids: t.Optional(
|
||||||
t.String(
|
t.String(
|
||||||
t.String({ description: 'The IDs for the icons you want to get' })
|
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', {
|
export const berryDashMarketplaceIcons = mysqlTable('marketplaceicons', {
|
||||||
id: bigint('id', { mode: 'number' }).primaryKey().autoincrement().notNull(),
|
id: varchar('id', { length: 36 }).notNull(),
|
||||||
uuid: varchar('uuid', { length: 36 }).notNull(),
|
|
||||||
userId: bigint('userId', { mode: 'number' }).notNull(),
|
userId: bigint('userId', { mode: 'number' }).notNull(),
|
||||||
data: longtext('data').notNull(),
|
data: longtext('data').notNull(),
|
||||||
hash: varchar('hash', { length: 128 }).notNull(),
|
hash: varchar('hash', { length: 128 }).notNull(),
|
||||||
timestamp: bigint('timestamp', { mode: 'number' }).notNull(),
|
timestamp: bigint('timestamp', { mode: 'number' }).notNull(),
|
||||||
state: tinyint('state').default(0).notNull(),
|
state: tinyint('state').default(0).notNull(),
|
||||||
price: bigint('price', { mode: 'number' }).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
|
const { connection: connection1, db: db1 } = dbInfo1
|
||||||
|
|
||||||
let dataQuery = context.query.data
|
let dataQuery = context.query.data
|
||||||
let uuidQuery = context.query.uuid
|
let idQuery = context.query.id
|
||||||
let idQuery = context.query.id ? parseInt(context.query.id, 10) : 0
|
let idsQuery: string | string[] = context.query.ids
|
||||||
let uuidsQuery = context.query.uuids
|
if (!idQuery && !idsQuery) {
|
||||||
let idsQuery = context.query.ids
|
|
||||||
if (!uuidQuery && !idQuery && !uuidsQuery && !idsQuery) {
|
|
||||||
connection0.end()
|
connection0.end()
|
||||||
connection1.end()
|
connection1.end()
|
||||||
return jsonResponse(
|
return jsonResponse(
|
||||||
{
|
{
|
||||||
success: false,
|
success: false,
|
||||||
message: 'Must have either ID, UUID, IDS, or UUIDS in params',
|
message: 'Must have UUID or UUIDS in params',
|
||||||
data: null
|
data: null
|
||||||
},
|
},
|
||||||
400
|
400
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (uuidsQuery) uuidsQuery = JSON.parse(uuidsQuery)
|
if (idsQuery) idsQuery = JSON.parse(idsQuery) as string[]
|
||||||
if (idsQuery) idsQuery = JSON.parse(idsQuery)
|
|
||||||
} catch {
|
} catch {
|
||||||
connection0.end()
|
connection0.end()
|
||||||
connection1.end()
|
connection1.end()
|
||||||
@@ -49,7 +46,7 @@ export async function handler (context: Context) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (idQuery || uuidQuery) {
|
if (idQuery) {
|
||||||
const icon = await db1
|
const icon = await db1
|
||||||
.select({
|
.select({
|
||||||
id: berryDashMarketplaceIcons.id,
|
id: berryDashMarketplaceIcons.id,
|
||||||
@@ -62,11 +59,7 @@ export async function handler (context: Context) {
|
|||||||
name: berryDashMarketplaceIcons.name
|
name: berryDashMarketplaceIcons.name
|
||||||
})
|
})
|
||||||
.from(berryDashMarketplaceIcons)
|
.from(berryDashMarketplaceIcons)
|
||||||
.where(
|
.where(eq(berryDashMarketplaceIcons.id, idQuery))
|
||||||
!uuidQuery
|
|
||||||
? eq(berryDashMarketplaceIcons.id, idQuery)
|
|
||||||
: eq(berryDashMarketplaceIcons.uuid, uuidQuery)
|
|
||||||
)
|
|
||||||
.limit(1)
|
.limit(1)
|
||||||
.execute()
|
.execute()
|
||||||
if (!icon[0]) {
|
if (!icon[0]) {
|
||||||
@@ -121,17 +114,7 @@ export async function handler (context: Context) {
|
|||||||
const icons = await db1
|
const icons = await db1
|
||||||
.select()
|
.select()
|
||||||
.from(berryDashMarketplaceIcons)
|
.from(berryDashMarketplaceIcons)
|
||||||
.where(
|
.where(inArray(berryDashMarketplaceIcons.id, idsQuery as string[]))
|
||||||
!uuidsQuery
|
|
||||||
? inArray(
|
|
||||||
berryDashMarketplaceIcons.id,
|
|
||||||
idsQuery as unknown as number[]
|
|
||||||
)
|
|
||||||
: inArray(
|
|
||||||
berryDashMarketplaceIcons.uuid,
|
|
||||||
uuidsQuery as unknown as string[]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.execute()
|
.execute()
|
||||||
|
|
||||||
const userIds = Array.from(new Set(icons.map(i => i.userId)))
|
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) {
|
} else if (body3.onlyShowValue === 1 && userId) {
|
||||||
filters.push(sql`${berryDashMarketplaceIcons.userId} != ${userId}`)
|
filters.push(sql`${berryDashMarketplaceIcons.userId} != ${userId}`)
|
||||||
} else if (body3.onlyShowValue === 2) {
|
} else if (body3.onlyShowValue === 2) {
|
||||||
filters.push(inArray(berryDashMarketplaceIcons.uuid, body3.currentIcons))
|
filters.push(inArray(berryDashMarketplaceIcons.id, body3.currentIcons))
|
||||||
} else if (body3.onlyShowValue === 3) {
|
} else if (body3.onlyShowValue === 3) {
|
||||||
filters.push(
|
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 hashResult = hash(atob(body.fileContent), 'sha512')
|
||||||
const uuid = crypto.randomUUID()
|
const id = crypto.randomUUID()
|
||||||
|
|
||||||
await db1.insert(berryDashMarketplaceIcons).values({
|
await db1.insert(berryDashMarketplaceIcons).values({
|
||||||
uuid,
|
id,
|
||||||
userId,
|
userId,
|
||||||
data: body.fileContent,
|
data: body.fileContent,
|
||||||
hash: hashResult,
|
hash: hashResult,
|
||||||
|
|||||||
Reference in New Issue
Block a user