Add a way to get splash texts
This commit is contained in:
@@ -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`
|
||||
--
|
||||
|
||||
@@ -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(
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
|
||||
29
src/routes/berrydash/splash-text/get.ts
Normal file
29
src/routes/berrydash/splash-text/get.ts
Normal 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' }
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user