(channelID string)
| 617 | } |
| 618 | |
| 619 | func (s *Service) wsOnConnected(channelID string) { |
| 620 | if s == nil || channelID == "" { |
| 621 | return |
| 622 | } |
| 623 | if !strings.HasPrefix(strings.ToLower(channelID), "aistudio-") { |
| 624 | return |
| 625 | } |
| 626 | if s.coreManager != nil { |
| 627 | if existing, ok := s.coreManager.GetByID(channelID); ok && existing != nil { |
| 628 | if !existing.Disabled && existing.Status == coreauth.StatusActive { |
| 629 | return |
| 630 | } |
| 631 | } |
| 632 | } |
| 633 | now := time.Now().UTC() |
| 634 | auth := &coreauth.Auth{ |
| 635 | ID: channelID, // keep channel identifier as ID |
| 636 | Provider: "aistudio", // logical provider for switch routing |
| 637 | Label: channelID, // display original channel id |
| 638 | Status: coreauth.StatusActive, |
| 639 | CreatedAt: now, |
| 640 | UpdatedAt: now, |
| 641 | Attributes: map[string]string{"runtime_only": "true"}, |
| 642 | Metadata: map[string]any{"email": channelID}, // metadata drives logging and usage tracking |
| 643 | } |
| 644 | log.Infof("websocket provider connected: %s", channelID) |
| 645 | s.emitAuthUpdate(context.Background(), watcher.AuthUpdate{ |
| 646 | Action: watcher.AuthUpdateActionAdd, |
| 647 | ID: auth.ID, |
| 648 | Auth: auth, |
| 649 | }) |
| 650 | } |
| 651 | |
| 652 | func (s *Service) wsOnDisconnected(channelID string, reason error) { |
| 653 | if s == nil || channelID == "" { |
nothing calls this directly
no test coverage detected