fix: align IM client interaction edge cases
This commit is contained in:
@@ -347,10 +347,10 @@ func preparePayloads(rcpt *push.Receipt, config *configType) ([]*jpushPayload, [
|
||||
var targets []t.Uid
|
||||
for _, uid := range uids {
|
||||
recipient := rcpt.To[uid]
|
||||
if recipient.Delivered > 0 {
|
||||
continue
|
||||
}
|
||||
userData := cloneData(data)
|
||||
if recipient.Delivered > 0 {
|
||||
userData["silent"] = "true"
|
||||
}
|
||||
topic := rcpt.Payload.Topic
|
||||
var audience map[string][]string
|
||||
if useAlias {
|
||||
|
||||
@@ -146,6 +146,30 @@ func TestPreparePayloadsCanUseRegistrationID(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPreparePayloadsDoesNotDropRecipientWithDeliveredSession(t *testing.T) {
|
||||
oldTokens := store.DevicePushTokens
|
||||
uid := types.Uid(42)
|
||||
store.DevicePushTokens = &testDevicePushTokenStore{devices: map[types.Uid][]types.DeviceDef{
|
||||
uid: {{DeviceId: "push-token", Platform: "ios"}},
|
||||
}}
|
||||
defer func() { store.DevicePushTokens = oldTokens }()
|
||||
useAlias := false
|
||||
config := &configType{Title: "MeetingIM", DefaultTTLSeconds: 86400, CallTTLSeconds: 60, UseAlias: &useAlias}
|
||||
payloads, _ := preparePayloads(&push.Receipt{
|
||||
TenantID: 7,
|
||||
To: map[types.Uid]push.Recipient{
|
||||
uid: {Delivered: 1},
|
||||
},
|
||||
Payload: push.Payload{What: push.ActMsg, Topic: "grpTopic", SeqId: 9, Timestamp: time.Now()},
|
||||
}, config)
|
||||
if len(payloads) != 1 {
|
||||
t.Fatalf("unexpected payload count: %d", len(payloads))
|
||||
}
|
||||
if payloads[0].Message == nil || payloads[0].Message.Extras["silent"] != "true" {
|
||||
t.Fatalf("expected silent payload for delivered recipient: %#v", payloads[0])
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildPayloadUsesShortTTLForCalls(t *testing.T) {
|
||||
config := &configType{Title: "MeetingIM", DefaultTTLSeconds: 86400, CallTTLSeconds: 60}
|
||||
payload := buildPayload(map[string][]string{"alias": {"usr1"}}, "p2pTopic", map[string]string{
|
||||
|
||||
Reference in New Issue
Block a user