Implement comprehensive connection caching system to prevent XMPP connection leaks and support HA environments:
- Add node-specific XMPP resources using format "{baseResource}-node-{diagnosticId[:8]}" for HA compatibility
- Implement thread-safe connection cache with mutex protection in UserManager
- Add cache-first lookup in GetUser/GetOrCreateUser methods to prevent duplicate connections
- Update lifecycle manager to efficiently check cached users instead of expensive KV store queries
- Add graceful shutdown cleanup to properly disconnect all cached connections
- Implement cache management methods: getCachedUser, cacheUser, removeCachedUser, getCachedUsers
- Update activity tracking to work with cached connections
- Add proper cache cleanup when users are disconnected or deleted
This prevents connection leaks identified in previous implementation while maintaining efficient ghost user lifecycle management with 30-minute inactivity timeout.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Extract bridge user detection logic into separate isBridgeUserMessage() function
- Fix gocritic ifElseChain issues by converting if-else to switch statements
- Fix gofmt formatting issues in client.go
- Fix revive naming issues by renaming XMPPUser to User and XMPPUserManager to UserManager
- Improve code organization and maintainability
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replace bridgeUser with bridgeClient (*xmppClient.Client) in XMPP bridge
- Update createXMPPClient to return XMPP client with TLS configuration
- Migrate connection, disconnection, and room operations to use bridgeClient
- Update Ping() and RoomExists() methods to use client methods directly
- Maintain bridge-agnostic user management system for additional users
- Fix formatting and import organization across bridge components
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit implements a complete multi-user bridge management system that allows bridges to control multiple users with async goroutine management and convenience methods for channel operations.
Key features:
- Bridge-agnostic BridgeUser interface with validation, identity, state management, channel operations, connection lifecycle, and goroutine lifecycle methods
- BridgeUserManager interface for user lifecycle management with bridge type identification
- XMPPUser implementation for XMPP bridge with XMPP client integration, connection monitoring, and room operations
- MattermostUser implementation for Mattermost bridge with API integration and channel management
- Updated Bridge interface to include GetUserManager() method
- Base UserManager implementation with generic user management logic
- Added Ping() and CheckChannelExists() methods to BridgeUser interface for health checking and room validation
- Updated bridge manager naming from Manager to BridgeManager for clarity
The system enables bridges to manage multiple users (like "Mattermost Bridge" user in XMPP) with proper state management, connection monitoring, and channel operations abstracted across different bridge protocols.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>