diff --git a/src/bot/orchestrator.ts b/src/bot/orchestrator.ts index 29ee879..74aaf87 100644 --- a/src/bot/orchestrator.ts +++ b/src/bot/orchestrator.ts @@ -219,55 +219,26 @@ export class BotOrchestrator { this._logger.info(`Post-auth URL: ${postAuthUrl.substring(0, 100)}`); // After login, Microsoft redirects to M365 (m365.cloud.microsoft/chat/). - // The "Continue on this browser" launcher ALWAYS leads to anonymous mode. - // Instead, navigate to teams.cloud.microsoft and use the meeting join from there. - // teams.cloud.microsoft is the new Teams domain where the auth session lives. - const { parseMeetingUrl } = await import('./meetingUrlParser'); - const parsed = parseMeetingUrl(this._meetingUrl); - const meetingId = parsed.meetingId || ''; - const passcode = parsed.passcode || ''; - - // Navigate to Teams on the cloud.microsoft domain (where auth cookies are) - // and try to join the meeting from within the authenticated app - const teamsCloudUrls = [ - // Direct meeting URL on new Teams domain - `https://teams.cloud.microsoft/meet/${meetingId}${passcode ? '?p=' + passcode : ''}`, - // Original meeting URL (teams.microsoft.com) - this._meetingUrl, - ]; + // Navigate back to the meeting URL. Now with auth cookies set, + // clicking "Continue on this browser" should lead to the authenticated + // Teams v2 Pre-Join page (with meeting title, no name input, "Room audio" option). + this._logger.info('Navigating back to meeting URL after auth...'); + await this._page!.goto(this._meetingUrl, { + waitUntil: 'domcontentloaded', + timeout: 30000, + }); - for (const url of teamsCloudUrls) { - this._logger.info(`Trying authenticated meeting URL: ${url.substring(0, 80)}`); - try { - await this._page!.goto(url, { - waitUntil: 'domcontentloaded', - timeout: 20000, - }); - await this._page!.waitForTimeout(5000); - - const resultUrl = this._page!.url(); - const pageContent = await this._page!.evaluate(() => document.body?.innerText?.substring(0, 500) || ''); - this._logger.info(`Result URL: ${resultUrl.substring(0, 100)}`); - this._logger.info(`Page content: ${pageContent.substring(0, 200)}`); - - // Check if we have the authenticated pre-join (no "Type your name", has "Join now") - if (pageContent.includes('Join now') && !pageContent.includes('Type your name') && !pageContent.includes('Enter the name')) { - this._logger.info('Found authenticated pre-join page!'); - break; - } - - // If launcher appears, DON'T click "Continue on this browser" (leads to anon) - // Instead try the next URL - if (pageContent.includes('Continue on this browser')) { - this._logger.info('Launcher appeared - skipping (would lead to anonymous)'); - continue; - } - - } catch (navErr) { - this._logger.warn(`Navigation to ${url.substring(0, 60)} failed: ${navErr}`); - continue; - } - } + // Click "Continue on this browser" - this time with auth cookies + // it should lead to the authenticated pre-join page + await this._joinProcedure!.handleLauncherIfPresent(); + + // Wait for Teams v2 pre-join page to load + await this._page!.waitForTimeout(8000); + + const postNavUrl = this._page!.url(); + const postNavContent = await this._page!.evaluate(() => document.body?.innerText?.substring(0, 300) || ''); + this._logger.info(`Post-auth navigation URL: ${postNavUrl.substring(0, 100)}`); + this._logger.info(`Post-auth page content: ${postNavContent.substring(0, 200)}`); // Verify we're on the authenticated pre-join page const pageText = await this._page!.evaluate(() => document.body?.innerText?.substring(0, 500) || '');