Skip to content

Add IM UserStatus service for im.user.status.* methods#462

Merged
mesilov merged 5 commits intov3-devfrom
claude/fix-b24-issue-430-kUadi
Apr 29, 2026
Merged

Add IM UserStatus service for im.user.status.* methods#462
mesilov merged 5 commits intov3-devfrom
claude/fix-b24-issue-430-kUadi

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 #430
License MIT

Description

This PR adds a new UserStatus service under src/Services/IM/User/Service/ that wraps four REST API methods for managing user status in Bitrix24:

  • im.user.status.get — retrieves the current user's status (online, idle, away, dnd, offline)
  • im.user.status.set — sets a custom status
  • im.user.status.idle.start — enables automatic "Away" status
  • im.user.status.idle.end — disables automatic "Away" status

Key Changes

New Files:

  • src/Services/IM/User/UserStatusType.php — String-backed enum for valid status values
  • src/Services/IM/User/Result/UserStatusResult.php — Custom result class with status(): string accessor
  • src/Services/IM/User/Service/UserStatus.php — Service class with four methods
  • tests/Unit/Services/IM/User/Service/UserStatusTest.php — Unit tests
  • tests/Integration/Services/IM/User/Service/UserStatusTest.php — Integration tests

Modified Files:

  • src/Services/IM/IMServiceBuilder.php — Added userStatus() method to expose the service
  • phpunit.xml.dist — Added integration test suite
  • Makefile — Added test target
  • CHANGELOG.md — Documented the new feature

Usage Example

$userStatus = $serviceBuilder->getIMScope()->userStatus();

// Get current status
$result = $userStatus->get();
$status = $result->status(); // Returns: "online", "idle", "away", "dnd", or "offline"

// Set status
$userStatus->set(UserStatusType::Online);

// Enable/disable automatic away
$userStatus->idleStart();
$userStatus->idleEnd();

Testing

  • Unit tests verify service instantiation
  • Integration tests validate all four methods against a real portal
  • All linting and type-checking passes (phpstan, deptrac, rector, cs-fixer)

https://claude.ai/code/session_015PC3VWnQepqMPssMpMacy6

claude added 2 commits April 29, 2026 05:03
- Add UserStatusType enum (online/idle/away/dnd/offline)
- Add UserStatusResult with status(): string accessor
- Add UserStatus service wrapping im.user.status.get, im.user.status.set,
  im.user.status.idle.start, im.user.status.idle.end
- Register IMServiceBuilder::userStatus() accessor
- Add unit test for UserStatus and IMServiceBuilderTest::testGetUserStatusService()
- Add integration test for all four methods
- Add integration_tests_im_user_status suite to phpunit.xml.dist
- Add test-integration-im-user-status target to Makefile
- Update CHANGELOG.md under 3.2.0 Unreleased → Added

https://claude.ai/code/session_015PC3VWnQepqMPssMpMacy6
@mesilov mesilov added this to the 3.2.0 milestone Apr 29, 2026
@mesilov mesilov self-assigned this Apr 29, 2026
mesilov added 3 commits April 29, 2026 12:14
# Conflicts:
#	Makefile
#	phpunit.xml.dist
#	src/Services/IM/IMServiceBuilder.php
#	tests/Unit/Services/IM/IMServiceBuilderTest.php
…`UserStatusResult::status()`

- Added `UserStatusItemResult` with `STATUS` property backed by `UserStatusType` enum.
- Updated `UserStatusResult::status()` to return `UserStatusItemResult` instead of string.
- Extended `UserStatusType` enum with new `break` status.
- Added unit and integration tests to ensure proper handling of `UserStatusItemResult`.

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

- Introduced generic support for backed-enum casting in `AbstractAnnotatedItem`.
- Removed specialized enum casting logic from `UserStatusItemResult`.
- Added unit tests for enum casting behavior with string-backed, int-backed, and nullable enums.
- Updated `CHANGELOG.md` to document enum-related improvements in `AbstractAnnotatedItem`.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
@mesilov mesilov merged commit 5cec7e7 into v3-dev Apr 29, 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.

2 participants