chore: detect server capabilities on connect
This commit is contained in:
parent
f31b80d92b
commit
4e4a290813
2 changed files with 7 additions and 24 deletions
|
@ -134,20 +134,6 @@ func (b *xmppBridge) createUserManager(cfg *config.Configuration, bridgeID strin
|
|||
return NewXMPPUserManager(bridgeID, log, store, b.api, cfg, b.bridgeClient)
|
||||
}
|
||||
|
||||
// waitForCapabilityDetection waits for server capability detection to complete
|
||||
func (b *xmppBridge) waitForCapabilityDetection() error {
|
||||
if b.bridgeClient == nil {
|
||||
return fmt.Errorf("bridge client not available")
|
||||
}
|
||||
|
||||
// Trigger capability detection synchronously
|
||||
if err := b.bridgeClient.DetectServerCapabilities(); err != nil {
|
||||
return fmt.Errorf("failed to detect server capabilities: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// checkXEP0077Support checks if the XMPP server supports XEP-0077 In-Band Registration
|
||||
func (b *xmppBridge) checkXEP0077Support() (bool, error) {
|
||||
if b.bridgeClient == nil {
|
||||
|
@ -237,11 +223,6 @@ func (b *xmppBridge) Start() error {
|
|||
return fmt.Errorf("failed to connect to XMPP server: %w", err)
|
||||
}
|
||||
|
||||
// Wait for server capability detection to complete before creating user manager
|
||||
if err := b.waitForCapabilityDetection(); err != nil {
|
||||
return fmt.Errorf("failed to detect server capabilities: %w", err)
|
||||
}
|
||||
|
||||
// Initialize proper user manager now that we're connected and server capabilities are detected
|
||||
b.userManager = b.createUserManager(cfg, b.bridgeID, b.logger, b.kvstore)
|
||||
|
||||
|
|
|
@ -182,11 +182,6 @@ func (c *Client) GetInBandRegistration() (*InBandRegistration, error) {
|
|||
return c.XEPFeatures.InBandRegistration, nil
|
||||
}
|
||||
|
||||
// DetectServerCapabilities discovers which XEPs are supported by the server (public method)
|
||||
func (c *Client) DetectServerCapabilities() error {
|
||||
return c.detectServerCapabilities()
|
||||
}
|
||||
|
||||
// detectServerCapabilities discovers which XEPs are supported by the server
|
||||
func (c *Client) detectServerCapabilities() error {
|
||||
if c.session == nil {
|
||||
|
@ -360,6 +355,13 @@ func (c *Client) Connect() error {
|
|||
return fmt.Errorf("failed to start session serving")
|
||||
}
|
||||
c.logger.LogInfo("XMPP client connected successfully", "jid", c.jidAddr.String())
|
||||
|
||||
// Automatically detect server capabilities after successful connection
|
||||
if err := c.detectServerCapabilities(); err != nil {
|
||||
c.logger.LogError("Failed to detect server capabilities automatically", "error", err)
|
||||
// Don't fail the connection for capability detection issues
|
||||
}
|
||||
|
||||
return nil
|
||||
case <-time.After(10 * time.Second):
|
||||
return fmt.Errorf("timeout waiting for session to be ready")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue