Commit graph

36 commits

Author SHA1 Message Date
a4fe14081d
chore: go mod tidy 2025-08-06 18:25:37 +02:00
7c37953c28
chore: fix lint issues 2025-08-06 18:25:25 +02:00
17ea21a579
chore: remove unused binaries 2025-08-06 18:25:02 +02:00
8dcb4b535c
pluginctl: updated to 0.1.3 2025-08-06 17:20:17 +02:00
d9c0215b93
feat: implement comprehensive loop prevention and architecture improvements
- Add comprehensive loop prevention at source level for all bridges:
  - XMPP bridge: Skip messages from own XMPP connection user
  - Mattermost bridge: Skip messages from bot user and remote users
- Remove cache from getOrCreateRemoteUser method for simplified user management
- Improve XMPP client architecture with direct handler delegation:
  - Add SetMessageHandler and GetJID methods to XMPP client
  - Move protocol normalization methods to client level
  - Implement handleIncomingXMPPMessage in XMPP bridge for business logic
- Fix message direction handling in XMPP message handler
- Add remote user invitation to shared channels via InviteRemoteToChannel API
- Clean up unused code and improve code formatting

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 17:16:52 +02:00
11a32afc53
refactor: improve XMPP client/bridge architecture separation
- Move protocol normalization methods to XMPP client (ExtractChannelID, ExtractUserInfo, ExtractMessageBody)
- Replace message channel aggregation with direct handler delegation pattern
- XMPP client now focuses purely on protocol concerns (connection, deduplication, normalization)
- XMPP bridge handles business logic (BridgeMessage creation, routing)
- Add SourceRemoteID field to BridgeMessage for better message tracking
- Remove unused message channel infrastructure in favor of mux.MessageHandlerFunc pattern

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 12:31:28 +02:00
8e9d87b176
feat: implement remote user creation for Mattermost bridge
Replace bot-based message posting with remote user creation system:

- Add getOrCreateRemoteUser() method to create/retrieve remote users on-demand
- Use plugin API to find existing users by username/email before creating new ones
- Generate usernames with bridge prefix and emails with bridge.{bridgeID} domain
- Set RemoteId field to BridgeMessage.SourceRemoteID for proper loop prevention
- Cache user mappings to avoid repeated API calls
- Post messages directly as remote users instead of bot with metadata
- Remove unused message formatting since messages are posted as actual users
- Log errors for failed user creation without complex retry logic

This enables authentic user attribution in Mattermost channels while maintaining
existing loop prevention mechanisms through the RemoteId field.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 12:29:55 +02:00
245f5f96db
chore: register bridge id 2025-08-06 08:36:51 +02:00
b1c6f21ea3
feat: implement OnSharedChannelsSyncMsg hook for bidirectional sync
Some checks are pending
ci / plugin-ci (push) Waiting to run
- Add PublishMessage method to BridgeManager interface and implementation
- Implement OnSharedChannelsSyncMsg hook to process Mattermost shared channel sync messages
- Add processSyncPost helper to convert Mattermost posts to bridge messages
- Route sync messages from Mattermost shared channels to XMPP bridge via message bus
- Handle user resolution with fallback to API calls for missing users
- Add comprehensive logging and error handling for sync operations
- Support routing of text messages from shared channels to XMPP rooms

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 19:40:12 +02:00
d21dcd2dd1
feat: implement sync and sync-reset commands for shared channel management
- Add GetRemoteID() method to Bridge interface for cursor operations
- Update bridge constructors to accept and store remoteID parameter
- Implement executeSyncCommand handler for forcing shared channel sync
- Implement executeSyncResetCommand handler for resetting sync cursor
- Add command registration for 'sync' and 'sync-reset' subcommands
- Enhance command handler with direct plugin API access for shared channel operations
- Add comprehensive validation and error handling for unmapped channels
- Support both SyncSharedChannel and UpdateSharedChannelCursor API methods

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 19:39:01 +02:00
5d81ca2154
fix: implement direct TCP connection to bypass DNS SRV discovery issues
- Add parseServerAddress helper to handle both URL and host:port formats
- Replace DialClientSession with NewClientSession and direct net.Dialer
- Bypass DNS SRV record lookups that were causing connection timeouts
- Support both simple host:port (localhost:5222) and URL formats
- Add proper error handling and connection cleanup

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 19:37:23 +02:00
4c6aeb2392
refactor: standardize bridge-agnostic terminology and remove unused kvstore functions
- Replace "Room" with "Channel" in bridge-agnostic contexts throughout codebase
- Update BridgeRoomID → BridgeChannelID in model structs and all references
- Change error messages to use consistent "Channel" terminology for user-facing text
- Update log keys: bridge_room_id → bridge_channel_id for consistency
- Clean up kvstore constants file by removing unused functions and constants:
  - Removed BuildXMPPUserKey, BuildMattermostUserKey, BuildGhostUserKey
  - Removed BuildXMPPEventPostKey, BuildXMPPReactionKey functions
  - Removed unused constants: KeyPrefixXMPPUser, KeyPrefixMattermostUser, etc.
  - Keep only actively used BuildChannelMapKey and ExtractIdentifierFromChannelMapKey
- Preserve XMPP-specific "Room" terminology in appropriate contexts (client methods, JIDs)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 12:33:19 +02:00
eb852662f7
feat: implement TTL cache for message deduplication and remove debug logging
- Replace manual map-based deduplication with jellydator/ttlcache/v3
- Add automatic cache eviction with 30-second TTL to prevent memory bloat
- Implement proper cache lifecycle management (start/stop)
- Remove emoji debug logs from bridge system and XMPP client
- Clean up verbose logging while maintaining essential error handling
- Update bridge interface method names for consistency

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 12:19:44 +02:00
7b56cb34c6
feat: implement bidirectional message bridge system with XMPP-Mattermost integration
This commit implements a comprehensive bridge-agnostic message routing system that enables
real-time bidirectional message synchronization between XMPP and Mattermost platforms.

Key features:
- Bridge-agnostic message types and structures for extensibility
- Central message bus system with publisher-subscriber pattern
- Complete Bridge interface implementation for both XMPP and Mattermost
- Message aggregation from multiple sources for scalability
- Loop prevention mechanisms to avoid infinite message cycles
- Buffered channels for high-performance message processing

Architecture highlights:
- Producer-consumer pattern for message routing between bridges
- Thread-safe goroutine lifecycle management with context cancellation
- Message handlers separated into dedicated files for maintainability
- Support for future bridge implementations (Slack, Discord, etc.)
- Markdown content standardization across all bridges

Files added:
- server/model/message.go: Core bridge-agnostic message structures
- server/bridge/messagebus.go: Central message routing system
- server/bridge/mattermost/message_handler.go: Mattermost-specific message processing
- server/bridge/xmpp/message_handler.go: XMPP-specific message processing

Files modified:
- server/bridge/manager.go: Integration with message bus and routing
- server/bridge/mattermost/bridge.go: Complete Bridge interface implementation
- server/bridge/xmpp/bridge.go: Message aggregation and interface completion
- server/model/bridge.go: Extended Bridge interface for bidirectional messaging
- server/xmpp/client.go: Enhanced message listening with mellium.im/xmpp

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-04 21:52:28 +02:00
69a67704f4
fix: prevent dangling XMPP connections during configuration updates
- Add getConfiguration() methods to both bridges for thread-safe config access
- Refactor UpdateConfiguration() methods to prevent mutex deadlock by releasing lock before blocking operations
- Fix XMPP bridge to properly disconnect existing bridgeClient before creating new one
- Add comprehensive timeout support to XMPP client (30s connection, 10s operations, 5s ping)
- Implement proper disconnection with offline presence
- Update all interfaces to use *config.Configuration for type safety

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-04 19:04:43 +02:00
65038fb7a2
feat: restore XMPP bridge to use direct client connection instead of bridge user
Some checks are pending
ci / plugin-ci (push) Waiting to run
- 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>
2025-08-04 18:04:10 +02:00
db8037ffbf
feat: implement comprehensive bridge-agnostic user management system
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>
2025-08-04 17:50:44 +02:00
ea1711e94c
feat: implement OnSharedChannelsPing hook with active bridge health checking
- Add Ping() method to Bridge interface for active connectivity testing
- Implement XMPP ping using disco#info query to server domain (fast & reliable)
- Implement Mattermost bridge ping using GetServerVersion API call
- Add comprehensive OnSharedChannelsPing hook with proper error handling
- Replace timeout-prone IQ ping with proven disco#info approach
- Add detailed logging for monitoring and debugging ping operations
- Fix doctor command to use new Ping method instead of TestConnection
- Performance: XMPP ping now completes in ~4ms vs previous 5s timeout

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-04 16:42:59 +02:00
35174c61a2
pluginctl: update to v0.1.2 2025-08-04 13:49:25 +02:00
a95ca8fb76
feat: implement comprehensive room validation and admin-only command access
- Add RoomExists and GetRoomMapping methods to Bridge interface
- Implement XMPP room existence checking using disco#info queries (XEP-0030)
- Add room validation in BridgeManager to prevent duplicate mappings and invalid rooms
- Enhance XMPP client with CheckRoomExists method and comprehensive logging
- Implement admin-only access control for all bridge commands
- Add user-friendly error messages with actionable troubleshooting steps
- Update doctor command with room existence testing and pre-join validation
- Add SimpleLogger implementation for standalone command usage

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-04 11:29:35 +02:00
1f45197aa8
feat: refactor channel mapping with structured parameters and shared channel integration
- Add ChannelMappingRequest and ChannelMappingDeleteRequest structs with validation
- Update BridgeManager interface to accept structured parameters instead of individual strings
- Implement proper user ID and team ID propagation to shared channels
- Add shared channel creation/deletion integration with Mattermost API
- Update command handlers to provide user and team context
- Enhance logging with comprehensive parameter tracking

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 19:10:40 +02:00
a5eb80817c
fix: correct plugin ID in manifest
Updates plugin ID to match proper naming convention from
com.mattermost.bridge-xmpp to com.mattermost.plugin-bridge-xmpp.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 18:30:27 +02:00
2e13d96dce
feat: implement centralized channel mapping management
Adds OnChannelMappingDeleted method to BridgeManager for centralized
cleanup of channel mappings across all bridge types. Updates slash
commands to use centralized management and fixes method naming
inconsistencies.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 18:18:10 +02:00
5d143808a3
feat: add direct message testing to XMPP doctor command
- Add reusable MessageBody and XMPPMessage structs to xmpp client
- Refactor SendMessage to use shared structs instead of inline definitions
- Add SendDirectMessage method for direct user messaging (type="chat")
- Enhance doctor command with --test-dm flag (enabled by default)
- Add testDirectMessage function that sends test message to admin@localhost
- Update help text, examples, and timing measurements for direct messages

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 16:58:02 +02:00
5551a8bc8d
feat: add /xmppbridge unmap command for channel unmapping
- Add DeleteChannelRoomMapping method to Bridge interface
- Implement channel unmapping logic in XMPP bridge (cache + KVStore removal)
- Add /xmppbridge unmap command handler with validation
- Bridge user automatically leaves XMPP room when unmapping
- Update command help text and autocomplete

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 16:44:59 +02:00
43f0fb1892
feat: implement bridge-agnostic channel mapping keys
- Replace channel mapping keys with bridge-agnostic pattern: channel_map_<bridge>_<identifier>
- XMPP mappings now use: channel_map_mattermost_<channelID> → roomJID, channel_map_xmpp_<roomJID> → channelID
- Update KV store constants with BuildChannelMapKey() and ExtractIdentifierFromChannelMapKey()
- Make KV store completely bridge-agnostic for future Matrix/Discord/Slack bridge support
- Fix getAllChannelMappings() to correctly read XMPP keys for room joining on startup
- Scalable design supports N bridges with consistent naming pattern

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 16:20:21 +02:00
8a8c9af611
feat: implement XMPP message sending and enhance MUC testing
- Implement proper SendMessage function with XML encoding and timeout protection
- Add message sending to MUC test workflow in doctor command
- Test results: join (16.87ms) → send message (75.46µs) → wait (5s) → leave (111.58µs)
- Enhanced doctor logging shows actual message content and comprehensive timing
- Validates complete bidirectional XMPP bridge functionality for production use

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 16:03:02 +02:00
d159c668c2
feat: implement production-ready MUC operations and comprehensive testing
- Implement proper XMPP MUC operations using mellium.im/xmpp/muc package
- Add session readiness checking to prevent blocking on room joins
- Create comprehensive bridge manager architecture with lifecycle management
- Add complete channel mapping functionality with KV store persistence
- Remove defensive logger nil checks as requested by user
- Enhance XMPP client doctor with MUC testing (join/wait/leave workflow)
- Add detailed dev server documentation for test room creation
- Implement timeout protection for all MUC operations
- Add proper error handling with fmt.Errorf instead of pkg/errors
- Successfully tested: MUC join in ~21ms, 5s wait, clean leave operation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 13:47:15 +02:00
4d6929bab6
feat: complete XMPP bridge implementation with configuration fixes
- Fix configuration loading by matching JSON field names with plugin manifest keys
- Move configuration to separate package to resolve type conflicts
- Implement bridge startup logic that initializes on OnActivate and updates on OnConfigurationChange
- Add certificate verification skip option for development/testing environments
- Create XMPP client initialization helper function to avoid code duplication
- Add SetOnlinePresence() method to XMPP client for presence management
- Set bridge user online presence automatically upon successful XMPP connection
- Remove unused mock generation and test files as requested
- Update bridge constructor to accept configuration parameter
- Implement proper bridge lifecycle management with Start/Stop methods

The bridge now properly loads configuration from admin console, creates XMPP connections
with appropriate TLS settings, and manages online presence for the bridge user.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-31 18:56:59 +02:00
07ff46624d
feat: implement XMPP client and development server infrastructure
## XMPP Client Implementation
- Create XMPP client with mellium.im/xmpp library
- Add SASL Plain authentication with TLS support
- Implement basic connection, ping, and disconnect functionality
- Add TLS certificate verification skip option for development

## Development Server Management
- Add custom makefile targets for XMPP server management
- Implement devserver_start, devserver_stop, devserver_status commands
- Add devserver_logs, devserver_clean, devserver_doctor commands
- Create comprehensive sidecar/README.md with setup instructions

## XMPP Client Doctor Tool
- Create cmd/xmpp-client-doctor diagnostic tool
- Add CLI flags for server configuration with sensible defaults
- Implement verbose logging and connection testing
- Include insecure TLS option for development environments

## Bridge Architecture Foundation
- Create placeholder bridge structs in proper package hierarchy
- Add server/bridge/mattermost and server/bridge/xmpp packages
- Update plugin initialization to create bridge instances
- Maintain clean separation between Mattermost and XMPP concerns

## Dependencies and Configuration
- Add mellium.im/xmpp dependencies to go.mod
- Fix plugin.json password field type validation
- Update README.md with XMPP bridge description and doctor usage
- Add .claude.md to .gitignore for local development notes

All tests passing. Ready for Phase 4 (Bridge Logic) implementation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-31 13:55:24 +02:00
f1a6cb138f
feat: implement XMPP bridge configuration and logger setup
- Add comprehensive XMPP settings schema to plugin.json
- Implement configuration struct with validation and helper methods
- Add configurable username prefix for XMPP users
- Set up logger in Plugin struct following Matrix bridge pattern
- Update KV store constants to use XMPP terminology
- Replace Matrix references with XMPP equivalents in test helpers

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-31 12:46:45 +02:00
202622f2c4
chore: retrieved base logic files from matrix bridge 2025-07-31 12:17:24 +02:00
b10a439a29
pluginctl: update assets 2025-07-31 12:17:06 +02:00
421b4f562f
chore: logo 2025-07-31 12:16:53 +02:00
1755c6e0b5
chore: sidecar folder with xmpp compose for testing 2025-07-31 12:16:36 +02:00
acbc69f7eb
Initial commit from mattermost-plugin-starter-template 2025-07-30 13:12:52 +02:00