Files
glchat/internal/meta/meta.go
T

59 lines
2.0 KiB
Go
Raw Normal View History

package meta
import "glchat/internal/config"
const APIVersion = "v1"
type Features struct {
RegistrationEnabled bool `json:"registration_enabled"`
AntiBotEnabled bool `json:"anti_bot_enabled"`
VoiceEnabled bool `json:"voice_enabled"`
// VoiceURL — адрес LiveKit для клиента (ws/wss), пусто при выключенном голосе.
VoiceURL string `json:"voice_url,omitempty"`
WebPushEnabled bool `json:"web_push_enabled"`
OAuthEnabled bool `json:"oauth_enabled"`
PasskeysEnabled bool `json:"passkeys_enabled"`
// OAuthProviders — включённые провайдеры входа (id): клиент рисует по
// списку кнопки, выключенные не показывает (Фаза 7).
OAuthProviders []string `json:"oauth_providers"`
}
type Response struct {
Name string `json:"name"`
Version string `json:"version"`
Commit string `json:"commit"`
BuildDate string `json:"build_date"`
APIVersion string `json:"api_version"`
BaseURL string `json:"base_url"`
FilesURL string `json:"files_url"`
GatewayURL string `json:"gateway_url"`
RTCPath string `json:"rtc_path"`
MaxUploadSize int64 `json:"max_upload_size"`
Features Features `json:"features"`
}
func New(cfg config.Config) Response {
return Response{
Name: cfg.InstanceName,
Version: cfg.Version,
Commit: cfg.Commit,
BuildDate: cfg.BuildDate,
APIVersion: APIVersion,
BaseURL: cfg.BaseURL(),
FilesURL: cfg.FilesURL(),
GatewayURL: cfg.GatewayURL(),
RTCPath: "/rtc",
MaxUploadSize: cfg.MaxUploadSize,
Features: Features{
RegistrationEnabled: true,
AntiBotEnabled: false,
VoiceEnabled: cfg.VoiceEnabled(),
VoiceURL: cfg.LiveKitURL,
WebPushEnabled: false,
OAuthEnabled: cfg.OAuthEnabled(),
PasskeysEnabled: cfg.WebAuthnEnabled(),
OAuthProviders: cfg.OAuthProviders(),
},
}
}