feat: add client call feature switches

This commit is contained in:
richjohnrambo
2026-09-03 21:05:33 +08:00
parent d6de2a0349
commit c1bfa503cf
9 changed files with 97 additions and 12 deletions
+14
View File
@@ -2315,6 +2315,7 @@ func TestServeIMBootstrapIncludesHomeCapabilities(t *testing.T) {
oldSecurity := store.Security
oldWorkbench := store.Workbench
oldRelations := store.Relations
oldThirdParty := store.ThirdPartyConfig
security := &testSecurityStore{
realName: &types.RealNameVerification{Status: "verified"},
unreadNotifications: 4,
@@ -2328,10 +2329,19 @@ func TestServeIMBootstrapIncludesHomeCapabilities(t *testing.T) {
store.Security = security
store.Relations = relations
store.Workbench = workbench
store.ThirdPartyConfig = testThirdPartyConfigStore{
"agora_enabled": "1",
"agora_auth_mode": "app_id",
"agora_app_id": "app123",
"agora_token_ttl_seconds": "3600",
"audio_call_enabled": "1",
"video_call_enabled": "1",
}
defer func() {
store.Security = oldSecurity
store.Relations = oldRelations
store.Workbench = oldWorkbench
store.ThirdPartyConfig = oldThirdParty
}()
req := httptest.NewRequest(http.MethodGet, "/v1/im/bootstrap", nil)
@@ -2347,6 +2357,10 @@ func TestServeIMBootstrapIncludesHomeCapabilities(t *testing.T) {
if data["features"] == nil || data["permissions"] == nil || data["system_topic"] == nil || data["message_policy"] == nil {
t.Fatalf("bootstrap missing home capabilities: %#v", data)
}
features := data["features"].(map[string]any)
if features["audio_call"] != true || features["video_call"] != true {
t.Fatalf("bootstrap call features disabled unexpectedly: %#v", features)
}
if security.realNameTenant != 7 || security.realNameUser != 42 {
t.Fatalf("bootstrap realname lookup scope: tenant=%d uid=%s", security.realNameTenant, security.realNameUser)
}