-
Notifications
You must be signed in to change notification settings - Fork 1
feat(thread): port getParticipants + close 8 fidelity gaps #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -430,6 +430,30 @@ async def all_messages(self) -> AsyncIterator[Message]: | |
| for msg in cached: | ||
| yield msg | ||
|
|
||
| async def get_participants(self) -> list[Author]: | ||
| """Return unique non-bot, non-self authors who've posted in the thread. | ||
|
|
||
| Mirrors ``getParticipants`` from the upstream TS SDK: seeds the | ||
| result with ``_current_message.author`` (if present and eligible), | ||
| then scans ``all_messages()`` oldest-first, skipping ``is_me`` and | ||
| ``is_bot`` authors and deduping by ``user_id``. | ||
| """ | ||
| seen: dict[str, Author] = {} | ||
|
|
||
| if ( | ||
| self._current_message is not None | ||
| and not self._current_message.author.is_me | ||
| and not self._current_message.author.is_bot | ||
| ): | ||
| seen[self._current_message.author.user_id] = self._current_message.author | ||
|
|
||
| async for msg in self.all_messages(): | ||
| if msg.author.is_me or msg.author.is_bot or msg.author.user_id in seen: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The check
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intentional upstream parity — in TS, |
||
| continue | ||
| seen[msg.author.user_id] = msg.author | ||
|
|
||
| return list(seen.values()) | ||
|
|
||
| # -- Subscriptions ------------------------------------------------------- | ||
|
|
||
| async def is_subscribed(self) -> bool: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1519,6 +1519,10 @@ async def refresh(self) -> None: | |
| """Refresh ``recent_messages`` from the API.""" | ||
| ... | ||
|
|
||
| async def get_participants(self) -> list[Author]: | ||
| """Return unique non-bot, non-self authors who've posted in the thread.""" | ||
| ... | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive — this is the standard |
||
|
|
||
| def create_sent_message_from_message(self, message: Message) -> SentMessage: | ||
| """Wrap a Message as a SentMessage with edit/delete capabilities.""" | ||
| ... | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Author.is_botis typed asbool | "unknown", but this check relies on truthiness, so authors withis_bot="unknown"are treated as bots and excluded from participants. That causesget_participants()to silently drop valid users in adapters that emit unknown bot status (for example Telegram fallback authors), so the method can return incomplete results even when non-self humans posted.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentional upstream parity — in TS,
!author.isBotalso excludes the string"unknown"because non-empty strings are truthy in JS. Explicitis Truewould diverge from vercel/chat. See thread.ts:359-384.