Add attributes to the splash text api

This commit is contained in:
Lncvrt committed 2026-02-21 14:12:41 -07:00
1 parent 345499ba64
commit 77eee04461
4 files changed
+42 -10

No files matched your search

+5 -4
View File
@@ -3,9 +3,9 @@
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Feb 13, 2026 at 09:50 AM
-- Server version: 11.8.5-MariaDB-log
-- PHP Version: 8.5.2
-- Generation Time: Feb 21, 2026 at 09:07 PM
-- Server version: 11.8.6-MariaDB-log
-- PHP Version: 8.5.3
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
@@ -79,7 +79,8 @@ CREATE TABLE `splashtexts` (
`userId` bigint(20) NOT NULL,
`content` varchar(72) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`timestamp` bigint(20) NOT NULL,
`state` tinyint(1) NOT NULL DEFAULT 0
`state` tinyint(1) NOT NULL DEFAULT 0,
`attributes` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPRESSED;
-- --------------------------------------------------------
+3 -1
View File
@@ -1303,7 +1303,9 @@ app.get('/berrydash/splash-text', berryDashSplashTextGetHandler, {
t.String({
hide: true
})
)
),
requester: t.Optional(t.String()),
clientversion: t.Optional(t.String())
})
})
app.post('/berrydash/splash-text', berryDashSplashTextPostHandler, {
+2 -1
View File
@@ -151,5 +151,6 @@ export const berryDashSplashTexts = mysqlTable('splashtexts', {
userId: bigint('userId', { mode: 'number' }).notNull(),
content: varchar('content', { length: 72 }).notNull(),
timestamp: bigint('timestamp', { mode: 'number' }).notNull(),
state: tinyint('state').default(0).notNull()
state: tinyint('state').default(0).notNull(),
attributes: text('attributes')
})
+32 -4
View File
@@ -1,8 +1,9 @@
import { getDatabaseConnection } from '../../../lib/util'
import { getDatabaseConnection, jsonResponse } from '../../../lib/util'
import { berryDashSplashTexts } from '../../../lib/tables'
import { eq } from 'drizzle-orm'
import { Context } from 'elysia'
export const handler = async () => {
export const handler = async (context: Context) => {
const dbInfo1 = getDatabaseConnection(1)
if (!dbInfo1)
@@ -12,9 +13,13 @@ export const handler = async () => {
})
const { connection: connection1, db: db1 } = dbInfo1
const requester = context.headers.requester
const clientVersion = context.headers.clientversion
const result = await db1
.select({
content: berryDashSplashTexts.content
content: berryDashSplashTexts.content,
attributes: berryDashSplashTexts.attributes
})
.from(berryDashSplashTexts)
.where(eq(berryDashSplashTexts.state, 1))
@@ -22,8 +27,31 @@ export const handler = async () => {
connection1.end()
return new Response(result.map(i => atob(i.content)).join('\n'), {
if (
!requester ||
!clientVersion ||
(requester == 'BerryDashClient' && clientVersion == '26.1')
) {
const data = result
.filter(v => {
if (clientVersion && clientVersion == '26.1' && v.attributes)
return false
return true
})
.map(i => atob(i.content))
return new Response(data.join('\n'), {
status: 200,
headers: { 'Content-Type': 'text/plain' }
})
} else {
return jsonResponse(
result.map(v => {
const data = v
v.content = atob(v.content)
if (v.attributes) v.attributes = JSON.parse(v.attributes)
return data
})
)
}
}