修正getAllUsers()不包含站长
This commit is contained in:
@@ -1,57 +0,0 @@
|
||||
/* eslint-disable no-console */
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { getConfig } from '@/lib/config';
|
||||
|
||||
export const runtime = 'nodejs';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const storageType = process.env.NEXT_PUBLIC_STORAGE_TYPE || 'localstorage';
|
||||
|
||||
// 调试信息
|
||||
const debugInfo = {
|
||||
storageType,
|
||||
envVars: {
|
||||
hasRedisUrl: !!process.env.REDIS_URL,
|
||||
hasUpstashUrl: !!process.env.UPSTASH_REDIS_REST_URL,
|
||||
hasUpstashToken: !!process.env.UPSTASH_REDIS_REST_TOKEN,
|
||||
hasKvrocksUrl: !!process.env.KVROCKS_URL,
|
||||
watchRoomEnabled: process.env.WATCH_ROOM_ENABLED,
|
||||
watchRoomServerType: process.env.WATCH_ROOM_SERVER_TYPE,
|
||||
hasWatchRoomExternalUrl: !!process.env.WATCH_ROOM_EXTERNAL_SERVER_URL,
|
||||
hasWatchRoomExternalAuth: !!process.env.WATCH_ROOM_EXTERNAL_SERVER_AUTH,
|
||||
},
|
||||
watchRoomConfig: {
|
||||
enabled: process.env.WATCH_ROOM_ENABLED === 'true',
|
||||
serverType: process.env.WATCH_ROOM_SERVER_TYPE || 'internal',
|
||||
externalServerUrl: process.env.WATCH_ROOM_EXTERNAL_SERVER_URL,
|
||||
externalServerAuth: process.env.WATCH_ROOM_EXTERNAL_SERVER_AUTH ? '***' : undefined,
|
||||
},
|
||||
configReadError: null as string | null,
|
||||
};
|
||||
|
||||
// 尝试读取配置(验证数据库连接)
|
||||
try {
|
||||
await getConfig();
|
||||
} catch (error) {
|
||||
debugInfo.configReadError = (error as Error).message;
|
||||
}
|
||||
|
||||
return NextResponse.json(debugInfo, {
|
||||
headers: {
|
||||
'Cache-Control': 'no-store',
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Debug API error:', error);
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: 'Failed to get debug info',
|
||||
details: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -650,7 +650,15 @@ export abstract class BaseRedisStorage implements IStorage {
|
||||
const users = await this.withRetry(() =>
|
||||
this.client.zRange(userListKey, 0, -1)
|
||||
);
|
||||
return users.map(u => ensureString(u));
|
||||
const userList = users.map(u => ensureString(u));
|
||||
|
||||
// 确保站长在列表中(站长可能不在数据库中,使用环境变量认证)
|
||||
const ownerUsername = process.env.USERNAME;
|
||||
if (ownerUsername && !userList.includes(ownerUsername)) {
|
||||
userList.unshift(ownerUsername);
|
||||
}
|
||||
|
||||
return userList;
|
||||
}
|
||||
|
||||
// ---------- 管理员配置 ----------
|
||||
|
||||
@@ -678,7 +678,15 @@ export class UpstashRedisStorage implements IStorage {
|
||||
const users = await withRetry(() =>
|
||||
this.client.zrange(userListKey, 0, -1)
|
||||
);
|
||||
return users.map(u => ensureString(u));
|
||||
const userList = users.map(u => ensureString(u));
|
||||
|
||||
// 确保站长在列表中(站长可能不在数据库中,使用环境变量认证)
|
||||
const ownerUsername = process.env.USERNAME;
|
||||
if (ownerUsername && !userList.includes(ownerUsername)) {
|
||||
userList.unshift(ownerUsername);
|
||||
}
|
||||
|
||||
return userList;
|
||||
}
|
||||
|
||||
// ---------- 管理员配置 ----------
|
||||
|
||||
Reference in New Issue
Block a user