- Updated .env.example to include new configuration options for the UltiAI branding and API endpoints. - Enhanced Nginx configuration to support new API routes for the MCP and WebSocket connections. - Introduced sub-filters for branding adjustments in Nginx responses. - Added new JavaScript patch for API endpoint adjustments. - Implemented tests for new API functionalities and improved error handling in the AI gateway.
31 lines
703 B
Go
31 lines
703 B
Go
package ai
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"github.com/jackc/pgx/v5"
|
|
"github.com/jackc/pgx/v5/pgxpool"
|
|
)
|
|
|
|
// ResolveExternalIDByEmail maps an Ultimail account email to users.external_id (Authentik sub).
|
|
func ResolveExternalIDByEmail(ctx context.Context, db *pgxpool.Pool, email string) (string, error) {
|
|
email = strings.TrimSpace(email)
|
|
if db == nil || email == "" {
|
|
return "", nil
|
|
}
|
|
var externalID string
|
|
err := db.QueryRow(ctx, `
|
|
SELECT external_id FROM users
|
|
WHERE lower(email) = lower($1) AND status != 'disabled'
|
|
LIMIT 1
|
|
`, email).Scan(&externalID)
|
|
if err != nil {
|
|
if err == pgx.ErrNoRows {
|
|
return "", nil
|
|
}
|
|
return "", err
|
|
}
|
|
return strings.TrimSpace(externalID), nil
|
|
}
|