fix: add call push category

This commit is contained in:
richjohnrambo
2026-09-18 13:38:57 +08:00
parent 192bdede33
commit 153f541078
3 changed files with 111 additions and 20 deletions
+18 -7
View File
@@ -174,11 +174,12 @@ func TestBuildPayloadUsesShortTTLForCalls(t *testing.T) {
expiresAt := time.Now().Add(30 * time.Second).UTC().Format(time.RFC3339Nano)
config := &configType{Title: "MeetingIM", DefaultTTLSeconds: 86400, CallTTLSeconds: 60}
payload := buildPayload(map[string][]string{"alias": {"usr1"}}, "p2pTopic", map[string]string{
"type": "call_invite",
"topic": "p2pTopic",
"seq": "30",
"call_type": "audio",
"expires_at": expiresAt,
"type": "call_invite",
"topic": "p2pTopic",
"seq": "30",
"call_type": "audio",
"caller_display": "张三",
"expires_at": expiresAt,
}, 0, config)
if payload.Options.TimeToLive > 30 {
t.Fatalf("unexpected ttl: %d", payload.Options.TimeToLive)
@@ -186,6 +187,12 @@ func TestBuildPayloadUsesShortTTLForCalls(t *testing.T) {
if payload.Notification.Android.Title != "语音通话" {
t.Fatalf("unexpected title: %s", payload.Notification.Android.Title)
}
if payload.Notification.IOS.Category != callCategory {
t.Fatalf("unexpected iOS category: %s", payload.Notification.IOS.Category)
}
if payload.Notification.IOS.Alert.Body != "张三邀请你语音通话" {
t.Fatalf("unexpected body: %s", payload.Notification.IOS.Alert.Body)
}
}
func TestPushDataExtractsCallFields(t *testing.T) {
@@ -198,8 +205,9 @@ func TestPushDataExtractsCallFields(t *testing.T) {
Webrtc: "started",
ExpiresAt: &expiresAt,
Content: map[string]any{
"callId": "call_1",
"callType": "audio",
"callId": "call_1",
"callType": "audio",
"caller_display": "张三",
},
Timestamp: time.Date(2026, 9, 4, 10, 0, 0, 0, time.UTC),
})
@@ -212,6 +220,9 @@ func TestPushDataExtractsCallFields(t *testing.T) {
if data["expires_at"] != expiresAt.Format(time.RFC3339Nano) {
t.Fatalf("unexpected expires_at: %#v", data)
}
if data["caller_display"] != "张三" {
t.Fatalf("unexpected caller_display: %#v", data)
}
}
func TestPreparePayloadsDropsExpiredCallInvite(t *testing.T) {