修正getAllUsers()不包含站长

This commit is contained in:
mtvpls
2025-12-25 00:00:22 +08:00
parent e26c412c47
commit 012a3beb5e
3 changed files with 18 additions and 59 deletions

View File

@@ -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;
}
// ---------- 管理员配置 ----------

View File

@@ -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;
}
// ---------- 管理员配置 ----------