Add a way to get splash texts

This commit is contained in:
2026-01-30 21:30:09 -07:00
parent f97e58161c
commit cb8c171dcf
4 changed files with 72 additions and 2 deletions

View File

@@ -3,7 +3,7 @@
-- https://www.phpmyadmin.net/ -- https://www.phpmyadmin.net/
-- --
-- Host: localhost -- 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 -- Server version: 12.1.2-MariaDB
-- PHP Version: 8.5.2 -- 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` -- Table structure for table `userdata`
-- --
CREATE TABLE `userdata` ( CREATE TABLE `userdata` (
`id` bigint(20) NOT NULL, `id` bigint(20) NOT NULL,
`token` varchar(512) NOT NULL,
`save_data` longtext NOT NULL DEFAULT '{}', `save_data` longtext NOT NULL DEFAULT '{}',
`legacy_high_score` bigint(20) NOT NULL DEFAULT 0 `legacy_high_score` bigint(20) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPRESSED; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPRESSED;
@@ -118,6 +131,12 @@ ALTER TABLE `chats`
ALTER TABLE `marketplaceicons` ALTER TABLE `marketplaceicons`
ADD PRIMARY KEY (`place`); ADD PRIMARY KEY (`place`);
--
-- Indexes for table `splashtexts`
--
ALTER TABLE `splashtexts`
ADD PRIMARY KEY (`id`);
-- --
-- Indexes for table `userdata` -- Indexes for table `userdata`
-- --
@@ -152,6 +171,12 @@ ALTER TABLE `chats`
ALTER TABLE `marketplaceicons` ALTER TABLE `marketplaceicons`
MODIFY `place` bigint(20) NOT NULL AUTO_INCREMENT; 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` -- AUTO_INCREMENT for table `userdata`
-- --

View File

@@ -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 berryDashChatroomReportPostHandler } from './routes/berrydash/chatroom/report/post'
import { handler as berryDashSplashTextGetHandler } from './routes/berrydash/splash-text/get'
dotenv.config({ quiet: true }) dotenv.config({ quiet: true })
const intNotStr = (name: string) => { 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('*', () => app.all('*', () =>
jsonResponse( jsonResponse(
{ {

View File

@@ -142,3 +142,11 @@ export const berryDashMarketplaceIcons = mysqlTable('marketplaceicons', {
.autoincrement() .autoincrement()
.notNull() .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()
})

View File

@@ -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' }
})
}