D
This commit is contained in:
@@ -143,6 +143,8 @@ export class XBrowserService implements OnModuleInit, OnModuleDestroy {
|
|||||||
|
|
||||||
async verifyCookie() {
|
async verifyCookie() {
|
||||||
const page = await this.newPage();
|
const page = await this.newPage();
|
||||||
|
|
||||||
|
try {
|
||||||
await page.goto('https://x.com/', {
|
await page.goto('https://x.com/', {
|
||||||
waitUntil: 'domcontentloaded',
|
waitUntil: 'domcontentloaded',
|
||||||
timeout: 30_000,
|
timeout: 30_000,
|
||||||
@@ -166,8 +168,14 @@ export class XBrowserService implements OnModuleInit, OnModuleDestroy {
|
|||||||
.catch(() => false);
|
.catch(() => false);
|
||||||
|
|
||||||
this.logger.log(`🔐 Session restore: ${isLoggedIn ? 'LOGGED IN' : 'GUEST (cookie có thể expired)'}`);
|
this.logger.log(`🔐 Session restore: ${isLoggedIn ? 'LOGGED IN' : 'GUEST (cookie có thể expired)'}`);
|
||||||
await page.close();
|
// await page.close();
|
||||||
return isLoggedIn;
|
return isLoggedIn;
|
||||||
|
} catch (er) {
|
||||||
|
this.logger.error(`Browser verify cookie fail: ${er.message}`);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
await page?.close().catch(() => null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async postTweet(
|
async postTweet(
|
||||||
|
|||||||
Reference in New Issue
Block a user