Skip to content

Add Chat service for im.chat.* support (#423)#442

Merged
mesilov merged 5 commits intov3-devfrom
feature/423-add-im-chat-service
Apr 20, 2026
Merged

Add Chat service for im.chat.* support (#423)#442
mesilov merged 5 commits intov3-devfrom
feature/423-add-im-chat-service

Conversation

@mesilov
Copy link
Copy Markdown
Collaborator

@mesilov mesilov commented Apr 18, 2026

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

Summary

Adds a new Chat service under the IM scope that wraps eight Bitrix24 REST methods for chat management:

  • im.chat.add — create a chat
  • im.chat.get — resolve a chat by linked entity type and id
  • im.chat.leave — remove the current user from a chat
  • im.chat.mute / im.chat.muteByDialog — mute notifications by CHAT_ID or DIALOG_ID (two explicit methods to keep each endpoint shape typed)
  • im.chat.setOwner — transfer chat ownership
  • im.chat.updateAvatar — update chat avatar (base64)
  • im.chat.updateColor — update chat color
  • im.chat.updateTitle — update chat title

Chat-specific string parameters are modelled as scope-local PHP 8.1 string-backed enums: ChatType, ChatColor, ChatEntityType. Result types: ChatItemResult + ChatResult (returns ?ChatItemResult to reflect that im.chat.get returns null when no chat matches).

IMServiceBuilder::chat() accessor wires the new service into the existing IM scope factory.

Usage

use Bitrix24\SDK\Services\IM\Chat\ChatEntityType;
use Bitrix24\SDK\Services\IM\Chat\ChatType;

$chatService = $serviceBuilder->getIMScope()->chat();

$chatId = $chatService->add(
    users: [42, 43],
    chatType: ChatType::Closed,
    title: 'Project discussion',
    chatEntityType: ChatEntityType::Calendar,
    entityId: 'PROJECT_42',
)->getId();

$chat = $chatService->get(ChatEntityType::Calendar, 'PROJECT_42')->chat();
if ($chat !== null) {
    $chatService->updateTitle($chat->ID, 'Renamed chat');
}

Test plan

  • make lint-cs-fixer
  • make lint-rector
  • make lint-phpstan
  • make lint-deptrac
  • make test-unit — 768 tests, 1959 assertions
  • make test-integration-im-chat — 12 tests, 17 assertions, all green against real portal

Closes #423

mesilov and others added 2 commits April 18, 2026 20:01
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@mesilov mesilov changed the title Add implementation plan for IM Chat service (#423) Add Chat service for im.chat.* support (#423) Apr 18, 2026
@mesilov
Copy link
Copy Markdown
Collaborator Author

mesilov commented Apr 18, 2026

@copilot resolve the merge conflicts in this pull request

@mesilov mesilov added this to the 3.2.0 milestone Apr 18, 2026
@mesilov mesilov linked an issue Apr 18, 2026 that may be closed by this pull request
16 tasks
@mesilov mesilov merged commit 43e6099 into v3-dev Apr 20, 2026
10 checks passed
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.

Add IM\Chat service for im.chat.* support

1 participant