-
Notifications
You must be signed in to change notification settings - Fork 10
feat: add leave_room, improve error handling, and refactor codebase #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Implement leave_room method to allow users to exit Webex rooms by deleting their membership - Add Membership struct and MembershipListParams for room membership management - Include UserError variant for better user-facing error messages - Add comprehensive test suite with mockito for HTTP mocking - Fix minor WebSocket event handling issue - Update GlobalIdType enum to support Membership operations
- Add field-level rename attributes to Membership struct fields to match API JSON format - Change Membership is_moderator and is_monitor from Option<bool> to bool with defaults - Change Membership created from Option<String> to String - Make Person struct fields optional where API may not return them (phone_numbers, nick_name, first_name, last_name, avatar) - Add rename attributes for Person fields (displayName, orgId) These changes ensure proper deserialization of API responses and fix errors when parsing membership and person data from Webex API.
…tion Implementation changes: - Fix api_delete to properly handle 204 No Content responses from DELETE endpoints - Implement leave_room() to delete user's membership from group rooms - Add get_user_id() method with caching to avoid repeated /people/me API calls - Add user_id field to Webex struct (Arc<Mutex<Option<String>>>) for thread-safe caching - Check room type before leaving - return error for 1:1 direct rooms (API limitation) - Remove broken personId=me filter, instead list all memberships and find user's API behavior: - Direct rooms cannot be left via Webex API (returns clear error message) - Group rooms can be left by deleting the user's membership - User ID is fetched once and cached for the lifetime of the Webex client Testing: - Add comprehensive test suite with 4 test cases: * test_leave_room_success - successful group room departure * test_leave_room_user_not_member - error when user not in room * test_leave_room_api_error - API error handling (403 response) * test_leave_room_direct_room_error - proper error for direct rooms - Update test mocks to include room details and people/me endpoints - All tests pass This fixes the issue where deleted rooms would reappear after app restart.
Allow both camelCase and PascalCase deserialization for Size and ImageSize enums to handle variations in API responses
- Add comprehensive HTTP status code checking with proper Error::StatusText wrapping - Parse JSON and HTML error responses with appropriate logging levels - Add ListResult struct flexibility to handle various API response formats - Improve device registration error handling with fallback mechanisms for 403 errors - Add organization listing error handling for insufficient permissions
- Add detailed error messages when device endpoints return 403 errors - Clearly indicate required spark:devices_write and spark:devices_read scopes - Improve error logging for mercury/WDM endpoint 403 responses - Help users understand OAuth scope requirements for event streams
- Box large Tungstenite error variant to reduce Result size - Refactor get_devices into smaller functions (complexity 43→acceptable) - Replace lazy_static with std::sync::LazyLock - Remove elidable lifetime annotations in API functions - Merge identical match arms - Apply clippy formatting suggestions throughout
mistastn
approved these changes
Dec 18, 2025
|
I do intend to do some work on this as well so I will bump the version as part of that. |
aknarts
approved these changes
Dec 18, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces the
leave_room()method for leaving group rooms, comprehensive HTTP error handling improvements, and various quality-of-life enhancements. The library is now version 0.10.1.Key Features
leave_room()method with user ID caching to leave group rooms (direct rooms return user-friendly error)get_user_id()cached method to avoid repeated/people/meAPI callsleave_roomfunctionality with mockito mockingspark:devices_writeandspark:devices_readOAuth scopesapi_deletenow properly handles 204 No Content responses from DELETE endpointslazy_static!withstd::sync::LazyLockAPI Changes
New Public Methods
Allows users to leave group rooms by deleting their membership. Returns
Error::UserErrorfor direct message rooms since the Webex API doesn't support leaving those.Internal method that fetches and caches the current user's ID to optimize repeated API calls.
New Error Variant
User-facing error messages for API limitations (e.g., cannot leave direct rooms).
Internal Changes
user_id: Arc<Mutex<Option<String>>>field for cachingTungstenitevariant to useBox<tungstenite::Error>to reduce Result sizeUserErrorvariant for user-facing messagesrest_apimethod with comprehensive error response parsingTesting
All tests pass (8 total):
leave_roomtests covering success, errors, and edge casesCommits
fix: correct serde attributes for Membership and Person structsfix: add serde aliases for adaptive card enum variantsfeat: add leave_room foundation with UserError and improved Tungstenite error handlingfeat: implement leave_room, improve error handling, and refactor for reduced complexityrefactor: apply clippy formatting suggestions to exampleschore: update .gitignore for Claude AI settingschore: bump version to 0.10.1chore: add nix flake for reproducible dev environment(dev)chore: add VSCode debug launch configurations(dev)chore: add editor ignore patterns and AI assistant documentation(dev)The last 3 commits (8-10) are development environment configurations and can be dropped if preferred, keeping only the library improvements (commits 1-7).