Skip to content

Add IM\Message service for im.message.* support#440

Merged
mesilov merged 21 commits intov3-devfrom
feature/426-add-im-message-service
Apr 21, 2026
Merged

Add IM\Message service for im.message.* support#440
mesilov merged 21 commits intov3-devfrom
feature/426-add-im-message-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 #426
License MIT

Summary

Implements a new service Bitrix24\SDK\Services\IM\Message\Service\Message
wrapping six im.message.* REST API methods under the im scope:

Method REST endpoint Result
add im.message.add AddedItemResult
update im.message.update UpdatedItemResult
delete im.message.delete DeletedItemResult
like im.message.like (with LikeAction enum: auto/plus/minus) UpdatedItemResult
share im.message.share (with ShareType enum: CHAT/TASK/POST/CALEND) UpdatedItemResult
command im.message.command UpdatedItemResult

The service is exposed via a new cached accessor IMServiceBuilder::message().
Two typed backed-string enums (LikeAction, ShareType) sit next to the service
so IDE autocomplete and static analysis can enforce valid values at call sites.

Usage

use Bitrix24\SDK\Services\IM\Message\Service\LikeAction;
use Bitrix24\SDK\Services\IM\Message\Service\ShareType;

\$messages = \$b24->getIMScope()->message();

// send a message and get its ID
\$messageId = \$messages->add('chat2941', 'Hello')->getId();

// edit it
\$messages->update(\$messageId, 'Hello (edited)')->isSuccess();

// toggle a Like
\$messages->like(\$messageId, LikeAction::plus)->isSuccess();

// create a task from a message
\$messages->share(\$messageId, 'chat2941', ShareType::task)->isSuccess();

// delete the message
\$messages->delete(\$messageId)->isSuccess();

Test plan

  • `make lint-cs-fixer` — passed
  • `make lint-rector` — passed
  • `make lint-phpstan` — passed
  • `make lint-deptrac` — passed (0 violations)
  • `make test-unit` — 770 tests, 1987 assertions, all green
  • `make test-integration-im-message` — 4 passed (add/update/delete/like); `testCommand` and `testShare` marked skipped (require chat-bot/chat fixtures not available in the default webhook)

Closes #426

🤖 Generated with Claude Code

mesilov and others added 2 commits April 18, 2026 14:00
@mesilov mesilov marked this pull request as draft April 18, 2026 08:01
@mesilov mesilov self-assigned this Apr 18, 2026
@mesilov mesilov added the enhancement in SDK New feature or request in SDK label Apr 18, 2026
@mesilov mesilov added this to the 3.2.0 milestone Apr 18, 2026
@mesilov mesilov changed the base branch from v3 to v3-dev April 18, 2026 08:01
mesilov and others added 4 commits April 18, 2026 19:34
Add a Core rules block to the "Creating a Pull Request" section:
- Agent must auto-create the PR via mcp__github__create_pull_request;
  never forward the pull/new URL as a manual-action prompt.
- PR base branch is fixed by API version: v3-dev for v3, dev for v1;
  never main.
- PR body always composed from .github/PULL_REQUEST_TEMPLATE.md read
  fresh from disk, not a memorised layout.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Implements six REST methods under the im scope:
- add: im.message.add -> AddedItemResult
- update: im.message.update -> UpdatedItemResult
- delete: im.message.delete -> DeletedItemResult
- like: im.message.like (LikeAction enum) -> UpdatedItemResult
- share: im.message.share (ShareType enum) -> UpdatedItemResult
- command: im.message.command -> UpdatedItemResult

Wires IMServiceBuilder::message() cached accessor, adds unit
and integration test suites (integration_tests_im_message),
Makefile target test-integration-im-message, and CHANGELOG
entry under 3.2.0 UNRELEASED.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…om/bitrix24/b24phpsdk into feature/426-add-im-message-service

# Conflicts:
#	tests/Unit/Services/IM/IMServiceBuilderTest.php
@mesilov mesilov changed the title Add implementation plan for im.message.* support (#426) Add IM\Message service for im.message.* support Apr 18, 2026
mesilov added 15 commits April 21, 2026 01:07
# Conflicts:
#	CHANGELOG.md
#	phpunit.xml.dist
#	src/Services/IM/IMServiceBuilder.php
#	tests/Unit/Services/IM/IMServiceBuilderTest.php
…p chat

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
…chments

Adds coverage for minimal USER block, avatar and link, and entity variants (user, bot, chat, and network).

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
…ttachments

Adds tests for plain text and BBCode variants, covering documented formats like USER, CHAT, URL, and formatting tags (B, U, I, S).

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
…chments

Adds tests for various LINK block configurations, including minimal payload, preview with description, HTML descriptions, and entity variants (user, chat, and network).

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
…achments

Adds tests for IMAGE block configurations, including minimal payload, images with preview and dimensions, and multiple images.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
…chments

Adds tests for various GRID block configurations, including BLOCK, LINE, ROW, and TABLE displays, as well as settings with BBCode values and entity links.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
…tachments

Adds tests for ATTACH block configurations, including full form with metadata and blocks, as well as a short form without a metadata wrapper.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
…chments

Adds tests for various FILE block configurations, including minimal link-only payload, full payload with name and size, and multiple file attachments.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
… attachments

Adds tests for various DELIMITER block configurations, including default settings, size-only blocks, and blocks with size and color options.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Adds tests for basic and advanced BBCode formatting payloads, including tags for styling, user mentions, hyperlinks, quotes, code blocks, and timestamps.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
…NU payloads

Adds tests for KEYBOARD payloads with buttons for links, actions, and newlines, as well as MENU payloads with link and action items. Includes validation of successful message creation.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
…rvice

Introduces a fluent API for constructing ATTACH payloads with dedicated typed objects (MESSAGE, LINK, USER, IMAGE, FILE, DELIMITER, GRID). Includes backward compatibility with legacy array-based payloads and enriches developer experience with clear, structured API design.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Removes outdated unit tests for the `Message` service in the IM message module, aligning with recent updates and changes in testing strategy.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
…ted tests

Introduces `RawAttach` as an object-based escape hatch for unsupported or vendor-extended ATTACH payloads in the IM message service. Includes unit tests for `RawAttach` and updated integration tests validating its usage with `Message`.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
@mesilov mesilov marked this pull request as ready for review April 21, 2026 18:50
@mesilov mesilov merged commit 80e59bb into v3-dev Apr 21, 2026
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement in SDK New feature or request in SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add IM\Message service for im.message.* support

1 participant