From cb8c171dcf2387ce1fcd57acc9763a63d3bb1c61 Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Fri, 30 Jan 2026 21:30:09 -0700 Subject: [PATCH] Add a way to get splash texts --- database/berrydashdatabase.sql | 29 +++++++++++++++++++++++-- src/index.ts | 8 +++++++ src/lib/tables.ts | 8 +++++++ src/routes/berrydash/splash-text/get.ts | 29 +++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 src/routes/berrydash/splash-text/get.ts diff --git a/database/berrydashdatabase.sql b/database/berrydashdatabase.sql index 66d9963..f0a265b 100644 --- a/database/berrydashdatabase.sql +++ b/database/berrydashdatabase.sql @@ -3,7 +3,7 @@ -- https://www.phpmyadmin.net/ -- -- Host: localhost --- Generation Time: Jan 30, 2026 at 02:12 AM +-- Generation Time: Jan 31, 2026 at 04:12 AM -- Server version: 12.1.2-MariaDB -- PHP Version: 8.5.2 @@ -69,13 +69,26 @@ CREATE TABLE `marketplaceicons` ( -- -------------------------------------------------------- +-- +-- Table structure for table `splashtexts` +-- + +CREATE TABLE `splashtexts` ( + `id` bigint(20) NOT NULL, + `userId` bigint(20) NOT NULL, + `content` varchar(72) NOT NULL, + `timestamp` bigint(20) NOT NULL, + `state` tinyint(1) NOT NULL DEFAULT 0 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPRESSED; + +-- -------------------------------------------------------- + -- -- Table structure for table `userdata` -- CREATE TABLE `userdata` ( `id` bigint(20) NOT NULL, - `token` varchar(512) NOT NULL, `save_data` longtext NOT NULL DEFAULT '{}', `legacy_high_score` bigint(20) NOT NULL DEFAULT 0 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPRESSED; @@ -118,6 +131,12 @@ ALTER TABLE `chats` ALTER TABLE `marketplaceicons` ADD PRIMARY KEY (`place`); +-- +-- Indexes for table `splashtexts` +-- +ALTER TABLE `splashtexts` + ADD PRIMARY KEY (`id`); + -- -- Indexes for table `userdata` -- @@ -152,6 +171,12 @@ ALTER TABLE `chats` ALTER TABLE `marketplaceicons` MODIFY `place` bigint(20) NOT NULL AUTO_INCREMENT; +-- +-- AUTO_INCREMENT for table `splashtexts` +-- +ALTER TABLE `splashtexts` + MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT; + -- -- AUTO_INCREMENT for table `userdata` -- diff --git a/src/index.ts b/src/index.ts index 96adbcd..ff89c80 100644 --- a/src/index.ts +++ b/src/index.ts @@ -45,6 +45,8 @@ import { handler as berryDashAccountSavePostHandler } from './routes/berrydash/a import { handler as berryDashChatroomReportPostHandler } from './routes/berrydash/chatroom/report/post' +import { handler as berryDashSplashTextGetHandler } from './routes/berrydash/splash-text/get' + dotenv.config({ quiet: true }) const intNotStr = (name: string) => { @@ -950,6 +952,12 @@ app.post( }) } ) +app.get('/berrydash/splash-text', berryDashSplashTextGetHandler, { + detail: { + description: 'The endpoint for getting splash texts.', + tags: ['Berry Dash', 'Splash Texts'] + } +}) app.all('*', () => jsonResponse( { diff --git a/src/lib/tables.ts b/src/lib/tables.ts index b2eaf44..66c17ea 100644 --- a/src/lib/tables.ts +++ b/src/lib/tables.ts @@ -142,3 +142,11 @@ export const berryDashMarketplaceIcons = mysqlTable('marketplaceicons', { .autoincrement() .notNull() }) + +export const berryDashSplashTexts = mysqlTable('splashtexts', { + id: bigint('id', { mode: 'number' }).primaryKey().autoincrement().notNull(), + userId: bigint('userId', { mode: 'number' }).notNull(), + content: varchar('content', { length: 72 }).notNull(), + timestamp: bigint('timestamp', { mode: 'number' }).notNull(), + state: tinyint('state').default(0).notNull() +}) diff --git a/src/routes/berrydash/splash-text/get.ts b/src/routes/berrydash/splash-text/get.ts new file mode 100644 index 0000000..f0a8f65 --- /dev/null +++ b/src/routes/berrydash/splash-text/get.ts @@ -0,0 +1,29 @@ +import { getDatabaseConnection } from '../../../lib/util' +import { berryDashSplashTexts } from '../../../lib/tables' +import { eq } from 'drizzle-orm' + +export async function handler () { + const dbInfo1 = getDatabaseConnection(1) + + if (!dbInfo1) + return new Response('', { + status: 200, + headers: { 'Content-Type': 'text/plain' } + }) + const { connection: connection1, db: db1 } = dbInfo1 + + const result = await db1 + .select({ + content: berryDashSplashTexts.content + }) + .from(berryDashSplashTexts) + .where(eq(berryDashSplashTexts.state, 1)) + .execute() + + connection1.end() + + return new Response(result.map(i => atob(i.content)).join('\n'), { + status: 200, + headers: { 'Content-Type': 'text/plain' } + }) +}