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>
This commit is contained in:
parent
07ff46624d
commit
4d6929bab6
12 changed files with 801 additions and 242 deletions
|
@ -21,8 +21,8 @@ type Client struct {
|
|||
username string
|
||||
password string
|
||||
resource string
|
||||
remoteID string // Plugin remote ID for metadata
|
||||
serverDomain string // explicit server domain for testing
|
||||
remoteID string // Plugin remote ID for metadata
|
||||
serverDomain string // explicit server domain for testing
|
||||
tlsConfig *tls.Config // custom TLS configuration
|
||||
|
||||
// XMPP connection
|
||||
|
@ -34,12 +34,12 @@ type Client struct {
|
|||
|
||||
// MessageRequest represents a request to send a message.
|
||||
type MessageRequest struct {
|
||||
RoomJID string `json:"room_jid"` // Required: XMPP room JID
|
||||
RoomJID string `json:"room_jid"` // Required: XMPP room JID
|
||||
GhostUserJID string `json:"ghost_user_jid"` // Required: Ghost user JID to send as
|
||||
Message string `json:"message"` // Required: Plain text message content
|
||||
HTMLMessage string `json:"html_message"` // Optional: HTML formatted message content
|
||||
ThreadID string `json:"thread_id"` // Optional: Thread ID
|
||||
PostID string `json:"post_id"` // Optional: Mattermost post ID metadata
|
||||
Message string `json:"message"` // Required: Plain text message content
|
||||
HTMLMessage string `json:"html_message"` // Optional: HTML formatted message content
|
||||
ThreadID string `json:"thread_id"` // Optional: Thread ID
|
||||
PostID string `json:"post_id"` // Optional: Mattermost post ID metadata
|
||||
}
|
||||
|
||||
// SendMessageResponse represents the response from XMPP when sending messages.
|
||||
|
@ -249,4 +249,24 @@ func (c *Client) GetUserProfile(userJID string) (*UserProfile, error) {
|
|||
DisplayName: userJID, // Default to JID if no display name available
|
||||
}
|
||||
return profile, nil
|
||||
}
|
||||
}
|
||||
|
||||
// SetOnlinePresence sends an online presence stanza to indicate the client is available
|
||||
func (c *Client) SetOnlinePresence() error {
|
||||
if c.session == nil {
|
||||
return errors.New("XMPP session not established")
|
||||
}
|
||||
|
||||
// Create presence stanza indicating we're available
|
||||
presence := stanza.Presence{
|
||||
Type: stanza.AvailablePresence,
|
||||
From: c.jidAddr,
|
||||
}
|
||||
|
||||
// Send the presence stanza
|
||||
if err := c.session.Encode(c.ctx, presence); err != nil {
|
||||
return errors.Wrap(err, "failed to send online presence")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue