Skip to content

Commit

Permalink
fix(firebase): ttl nil pointer (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmurayama authored Nov 29, 2024
1 parent 5020846 commit 3110398
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions extensions/firebase/client/firebase.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"context"
"encoding/json"
"errors"
"time"

firebase "firebase.google.com/go/v4"
"firebase.google.com/go/v4/messaging"
"github.com/sirupsen/logrus"
"github.com/topfreegames/pusher/interfaces"
"google.golang.org/api/option"
"time"
)

type firebaseClientImpl struct {
Expand Down Expand Up @@ -122,12 +123,13 @@ func toFirebaseMessage(message interfaces.Message) messaging.Message {
if message.Notification.TitleLocArgs != "" {
firebaseMessage.Android.Notification.TitleLocArgs = []string{message.Notification.TitleLocArgs}
}
}

if message.TimeToLive != nil {
secs := int(*message.TimeToLive)
ttl := time.Duration(secs) * time.Second
firebaseMessage.Android.TTL = &ttl
if message.TimeToLive != nil {
secs := int(*message.TimeToLive)
ttl := time.Duration(secs) * time.Second
// Add TTL only if there is a Notification, otherwise fails with nil pointer
firebaseMessage.Android.TTL = &ttl
}
}

return firebaseMessage
Expand Down

0 comments on commit 3110398

Please sign in to comment.