Skip to content

Add IM\ChatUser service for im.chat.user.* API support#467

Open
mesilov wants to merge 1 commit intov3-devfrom
claude/implement-issue-424-fGpaU
Open

Add IM\ChatUser service for im.chat.user.* API support#467
mesilov wants to merge 1 commit intov3-devfrom
claude/implement-issue-424-fGpaU

Conversation

@mesilov
Copy link
Copy Markdown
Collaborator

@mesilov mesilov commented Apr 29, 2026

Q A
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #424
License MIT

Description

This PR implements a new ChatUser service under src/Services/IM/Chat/Service/ that wraps three Bitrix24 REST API methods for managing chat participants:

  • im.chat.user.add — Add participants to a chat
  • im.chat.user.delete — Remove a participant from a chat
  • im.chat.user.list — List participant user IDs of a chat

Changes

New files:

  • src/Services/IM/Chat/Service/ChatUser.php — Service class with three public methods (add, delete, list)
  • src/Services/IM/Chat/Result/ChatUserListResult.php — Result class for the list method, providing getUserIds(): int[]
  • tests/Unit/Services/IM/Chat/Service/ChatUserTest.php — Unit test verifying service instantiation
  • tests/Integration/Services/IM/Chat/Service/ChatUserTest.php — Integration tests covering all three methods

Modified files:

  • src/Services/IM/IMServiceBuilder.php — Added chatUser(): ChatUser accessor method with service caching
  • phpunit.xml.dist — Added integration_tests_im_chat_user test suite
  • Makefile — Added test-integration-im-chat-user target
  • CHANGELOG.md — Documented the new feature

Usage Example

$imScope = $serviceBuilder->getIMScope();
$chatUserService = $imScope->chatUser();

// Add participants
$result = $chatUserService->add($chatId, [1, 2, 3]);

// Remove a participant
$result = $chatUserService->delete($chatId, 2);

// List participants
$userIds = $chatUserService->list($chatId)->getUserIds();

Testing

  • Unit test verifies service instantiation with NullCore
  • Integration tests cover all three methods with real API calls:
    • testList — Creates a chat and verifies participant list
    • testAdd — Adds a user and verifies they appear in the participant list
    • testDelete — Removes a user and verifies success
  • Tests handle multi-user portal scenarios gracefully with skip markers

All tests pass and comply with deptrac layer constraints.

https://claude.ai/code/session_012fip6Y4VZxNBCHGhBDXM9H

- ChatUser service wraps im.chat.user.add, im.chat.user.delete, im.chat.user.list
- ChatUserListResult returns flat int[] of participant user IDs
- IMServiceBuilder::chatUser() exposes the new service
- Unit and integration tests added
- phpunit.xml.dist suite integration_tests_im_chat_user added
- Makefile target test-integration-im-chat-user added
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 86d065dcdf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +40 to +45
public function add(int $chatId, array $userIds, bool $hideHistory = false): UpdatedItemResult
{
return new UpdatedItemResult($this->core->call('im.chat.user.add', [
'CHAT_ID' => $chatId,
'USERS' => $userIds,
'HIDE_HISTORY' => $hideHistory ? 'Y' : 'N',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve API default history hiding in chatUser add

When add() is called without the third argument, this implementation sends HIDE_HISTORY = 'N', which inverts the Bitrix24 method default (Y) and exposes prior chat history to newly added users. This is a behavior regression for callers relying on API defaults and can leak historical messages unless every call site explicitly opts in to hiding history.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants