更新依赖项,添加 flowme 插入触发器和监听器;重构数据库连接管理;优化用户路由和 SSE 处理
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user