fix: re-prime on chat switch; native Playwright click for profile cards
This commit is contained in:
parent
196acbac47
commit
a7835c3057
@ -180,6 +180,12 @@ class Monitor:
|
|||||||
_clear_line()
|
_clear_line()
|
||||||
print(f"Chat: {current_chat}")
|
print(f"Chat: {current_chat}")
|
||||||
last_chat = current_chat
|
last_chat = current_chat
|
||||||
|
if skip_existing:
|
||||||
|
# Neuer Chat — bestehende Nachrichten überspringen
|
||||||
|
try:
|
||||||
|
self.poll_new_messages()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@ -37,23 +37,31 @@ class Resolver:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def _extract_email_from_profile(self, display_name: str) -> str | None:
|
def _extract_email_from_profile(self, display_name: str) -> str | None:
|
||||||
# Click the first visible span whose text exactly matches the display name.
|
# Use Playwright's native click (real mouse events) to trigger the Teams profile card.
|
||||||
# Works for both channel meetings (fui-StyledText spans) and meeting chat.
|
# Try multiple selectors that contain the sender's name.
|
||||||
clicked = self._page.evaluate("""(name) => {
|
selectors = [
|
||||||
for (const span of document.querySelectorAll('span')) {
|
f"[data-tid='message-author-name']:has-text('{display_name}')",
|
||||||
if (span.textContent.trim() === name && span.offsetParent !== null) {
|
f"[data-tid='reply-message-header'] span:has-text('{display_name}')",
|
||||||
span.click();
|
f"span:has-text('{display_name}')",
|
||||||
return true;
|
]
|
||||||
}
|
|
||||||
}
|
clicked = False
|
||||||
return false;
|
for selector in selectors:
|
||||||
}""", display_name)
|
try:
|
||||||
|
loc = self._page.locator(selector).first
|
||||||
|
if loc.is_visible(timeout=1000):
|
||||||
|
loc.click()
|
||||||
|
clicked = True
|
||||||
|
break
|
||||||
|
except Exception:
|
||||||
|
continue
|
||||||
|
|
||||||
if not clicked:
|
if not clicked:
|
||||||
print(f" Sender '{display_name}' nicht im Chat gefunden.")
|
print(f" Sender '{display_name}' nicht im Chat gefunden.")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# Wait for profile card, then extract email from mailto link
|
||||||
self._page.wait_for_selector(_PROFILE_EMAIL_SELECTOR, timeout=5000)
|
self._page.wait_for_selector(_PROFILE_EMAIL_SELECTOR, timeout=5000)
|
||||||
email_el = self._page.query_selector(_PROFILE_EMAIL_SELECTOR)
|
email_el = self._page.query_selector(_PROFILE_EMAIL_SELECTOR)
|
||||||
email = None
|
email = None
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user