mirror of https://github.com/Nofated095/Q2TG.git
perf: 减少 session 显错
This commit is contained in:
parent
f5602f81b7
commit
1ba49b6029
|
@ -3,6 +3,8 @@ import db from '../providers/db';
|
||||||
import { AuthKey } from 'telegram/crypto/AuthKey';
|
import { AuthKey } from 'telegram/crypto/AuthKey';
|
||||||
import { getLogger } from 'log4js';
|
import { getLogger } from 'log4js';
|
||||||
|
|
||||||
|
const PASS = () => 0;
|
||||||
|
|
||||||
export default class TelegramSession extends MemorySession {
|
export default class TelegramSession extends MemorySession {
|
||||||
private dbId: number;
|
private dbId: number;
|
||||||
private log = getLogger('TelegramSession');
|
private log = getLogger('TelegramSession');
|
||||||
|
@ -54,7 +56,8 @@ export default class TelegramSession extends MemorySession {
|
||||||
where: { id: this.dbId },
|
where: { id: this.dbId },
|
||||||
data: { dcId, serverAddress, port },
|
data: { dcId, serverAddress, port },
|
||||||
})
|
})
|
||||||
.then(e => this.log.trace('DC update result', e));
|
.then(e => this.log.trace('DC update result', e))
|
||||||
|
.catch(PASS);
|
||||||
}
|
}
|
||||||
|
|
||||||
set authKey(value: AuthKey | undefined) {
|
set authKey(value: AuthKey | undefined) {
|
||||||
|
@ -64,7 +67,8 @@ export default class TelegramSession extends MemorySession {
|
||||||
where: { id: this.dbId },
|
where: { id: this.dbId },
|
||||||
data: { authKey: value?.getKey() || null },
|
data: { authKey: value?.getKey() || null },
|
||||||
})
|
})
|
||||||
.then(e => this.log.trace('authKey update result', e));
|
.then(e => this.log.trace('authKey update result', e))
|
||||||
|
.catch(PASS);
|
||||||
}
|
}
|
||||||
|
|
||||||
get authKey() {
|
get authKey() {
|
||||||
|
@ -97,7 +101,8 @@ export default class TelegramSession extends MemorySession {
|
||||||
name: e[4] && e[4].toString(),
|
name: e[4] && e[4].toString(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(e => this.log.trace('Entity update result', e));
|
.then(e => this.log.trace('Entity update result', e))
|
||||||
|
.catch(PASS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,7 +301,7 @@ export default class ConfigService {
|
||||||
const chatForUser = await this.tgUser.getChat(Number(forwardPair.tgChatId))
|
const chatForUser = await this.tgUser.getChat(Number(forwardPair.tgChatId))
|
||||||
if(chatForUser.entity instanceof Api.Chat){
|
if(chatForUser.entity instanceof Api.Chat){
|
||||||
this.log.info('升级群组 ', chatForUser.id);
|
this.log.info('升级群组 ', chatForUser.id);
|
||||||
console.log(await chatForUser.migrate());
|
await chatForUser.migrate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue