feat: follow lite forum updates
This commit is contained in:
1 parent
f59739e36f
commit
b42944b687
38 files changed
+1433
-71
No files matched your search
@@ -2,6 +2,7 @@
|
||||
import pool from '@/lib/db';
|
||||
import { getUser, requireAdmin } from '@/lib/auth';
|
||||
import { jsonWithEtag } from '@/lib/http-cache';
|
||||
import { loadSmtpConfig, isConfigComplete } from '@/lib/mailer';
|
||||
|
||||
const VERSION_COMMIT = (process.env.FORUMLIFY_COMMIT || 'unknown').slice(0, 7);
|
||||
|
||||
@@ -15,10 +16,14 @@ export async function GET(req) {
|
||||
`INSERT INTO settings (key, value) VALUES ('forum_name', 'Forumlify')
|
||||
ON CONFLICT (key) DO NOTHING`
|
||||
);
|
||||
const r = await pool.query('SELECT key, value FROM settings ORDER BY key');
|
||||
const r = await pool.query(`SELECT key, value FROM settings
|
||||
WHERE key = ANY($1::text[]) ORDER BY key`,
|
||||
[['forum_name', 'favicon_url', 'favicon_version', 'custom_css_enabled', 'email_verify_required']]);
|
||||
const settings = {};
|
||||
r.rows.forEach((row) => { settings[row.key] = row.value; });
|
||||
delete settings.favicon_object;
|
||||
const config = await loadSmtpConfig();
|
||||
settings.smtp_ready = isConfigComplete(config);
|
||||
settings.email_verify_required = settings.email_verify_required === 'true' && settings.smtp_ready;
|
||||
// 兜底:即使插入失败也保证返回 forum_name
|
||||
if (!settings.forum_name) settings.forum_name = 'Forumlify';
|
||||
settings.version_commit = VERSION_COMMIT;
|
||||
|
||||
Reference in new issue
Block a user