diff --git a/database/berrydashdatabase.sql b/database/berrydashdatabase.sql index 5ceeabe..68fbf72 100644 --- a/database/berrydashdatabase.sql +++ b/database/berrydashdatabase.sql @@ -3,7 +3,7 @@ -- https://www.phpmyadmin.net/ -- -- 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 -- PHP Version: 8.5.2 @@ -56,15 +56,15 @@ CREATE TABLE `chats` ( -- CREATE TABLE `marketplaceicons` ( - `id` bigint(20) NOT NULL, - `uuid` varchar(36) NOT NULL, + `id` varchar(36) NOT NULL, `userId` bigint(20) NOT NULL, `data` mediumtext NOT NULL, `hash` varchar(128) NOT NULL, `timestamp` bigint(20) NOT NULL, `state` tinyint(1) 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; -- -------------------------------------------------------- @@ -116,7 +116,7 @@ ALTER TABLE `chats` -- Indexes for table `marketplaceicons` -- ALTER TABLE `marketplaceicons` - ADD PRIMARY KEY (`id`); + ADD PRIMARY KEY (`place`); -- -- Indexes for table `userdata` @@ -150,7 +150,7 @@ ALTER TABLE `chats` -- AUTO_INCREMENT for 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` diff --git a/src/index.ts b/src/index.ts index 91bed05..b326043 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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' }) diff --git a/src/lib/tables.ts b/src/lib/tables.ts index 1e36108..084ea1e 100644 --- a/src/lib/tables.ts +++ b/src/lib/tables.ts @@ -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() }) diff --git a/src/routes/berrydash/icon-marketplace/icon/get.ts b/src/routes/berrydash/icon-marketplace/icon/get.ts index 40b8249..bafbde9 100644 --- a/src/routes/berrydash/icon-marketplace/icon/get.ts +++ b/src/routes/berrydash/icon-marketplace/icon/get.ts @@ -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))) diff --git a/src/routes/berrydash/icon-marketplace/post.ts b/src/routes/berrydash/icon-marketplace/post.ts index 071eb42..d72551d 100644 --- a/src/routes/berrydash/icon-marketplace/post.ts +++ b/src/routes/berrydash/icon-marketplace/post.ts @@ -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)) ) } } diff --git a/src/routes/berrydash/icon-marketplace/upload/post.ts b/src/routes/berrydash/icon-marketplace/upload/post.ts index 8675099..445c2f9 100644 --- a/src/routes/berrydash/icon-marketplace/upload/post.ts +++ b/src/routes/berrydash/icon-marketplace/upload/post.ts @@ -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,