更新依赖项,添加 flowme 插入触发器和监听器;重构数据库连接管理;优化用户路由和 SSE 处理

This commit is contained in:
2026-02-01 03:58:40 +08:00
parent 7c61bd3ac5
commit 82c9b834e9
16 changed files with 412 additions and 219 deletions

View File

@@ -183,7 +183,7 @@ export class User extends Model {
avatar: this.avatar,
orgs,
};
if(this.data?.canChangeUsername) {
if (this.data?.canChangeUsername) {
info.canChangeUsername = this.data.canChangeUsername;
}
const tokenUser = this.tokenUser;
@@ -232,6 +232,17 @@ export class User extends Model {
async expireOrgs() {
await redis.del(`user:${this.id}:orgs`);
}
static async getUserNameById(id: string) {
const redisName = await redis.get(`user:id:${id}:name`);
if (redisName) {
return redisName;
}
const user = await User.findByPk(id);
if (user?.username) {
await redis.set(`user:id:${id}:name`, user.username, 'EX', 60 * 60); // 1 hour
}
return user?.username;
}
}
export type SyncOpts = {
alter?: boolean;