Запрос списка участников чата/группы.#75
Conversation
📝 WalkthroughWalkthroughAdds chat-member retrieval support with a Pydantic request payload, API service method, pagination marker handling, member model binding, and a client-facing chat mixin wrapper. ChangesChat member retrieval
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant ChatMixin
participant ChatService
participant ChatAPI
ChatMixin->>ChatService: get_chat_members(chat_id, marker)
ChatService->>ChatAPI: CHAT_MEMBERS with GetChatMembersPayload
ChatAPI-->>ChatService: members and next marker
ChatService-->>ChatMixin: bound Member models and next marker
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/pymax/infra/chat.py`:
- Around line 214-228: Update get_chat_members to follow pagination until all
member pages are retrieved, using each response’s next-page marker to request
subsequent pages and combining the results into one list. Preserve the existing
chat_id and optional marker as the starting point, and return the complete
member collection through the public wrapper.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7176c637-8ae3-44bc-ac3d-88ae3988785c
📒 Files selected for processing (3)
src/pymax/api/chats/payloads.pysrc/pymax/api/chats/service.pysrc/pymax/infra/chat.py
| async def get_chat_members(self, chat_id: int, marker: int | None = None) -> list[Member]: | ||
| """Возвращает участников чата по ID. | ||
|
|
||
| Args: | ||
| chat_id: ID чата. | ||
| marker: Маркер пагинации. Если ``None``, запрашивается первая | ||
| страница. | ||
|
|
||
| Returns: | ||
| Список участников. | ||
|
|
||
| Raises: | ||
| PyMaxError: Если сервер не вернул участников. | ||
| """ | ||
| return await self._app.api.chats.get_chat_members(chat_id, marker) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Make the public wrapper complete pagination.
This wrapper exposes a method described as retrieving chat members, but it forwards a single-page request and provides no next-page marker. Users cannot obtain members beyond the first 50 through the documented API.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/pymax/infra/chat.py` around lines 214 - 228, Update get_chat_members to
follow pagination until all member pages are retrieved, using each response’s
next-page marker to request subsequent pages and combining the results into one
list. Preserve the existing chat_id and optional marker as the starting point,
and return the complete member collection through the public wrapper.
|
Спасибо за PR Проблема в том, что по моему Нужно возвращать либо |
А как насчет варианта самим проходится и отдавать всех подписчиков? |
|
Или как вы предложили: Вариант с моделью выглядит как излишний, тут частная ситуация. |
|
Пользователей может быть слишком много или юзеру нужно ограниченное количество |
|
Так, еще одна проблема, нету параметра |
Описание
Добавляет возможность получения списка участников чата или группы.
При работе с библиотекой оказалось, что chat = await client.get_chat(channel_id) и последующий chat.participants выдают только 1 участника. Проверил в протоколе - действительно, данные не передаются. Написал метод по получению всех участников.
Тип изменений
Связанные задачи / Issue
Ссылка на issue, если есть: #
Тестирование
Покажите пример кода, который проверяет изменения: