send push notifications regardless of online status
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
pbpusher "github.com/flowy-live/llink/genproto/llink/pusher"
|
||||
"github.com/flowy-live/llink/internal/billing"
|
||||
"github.com/flowy-live/llink/internal/db"
|
||||
"github.com/flowy-live/llink/internal/depot"
|
||||
@@ -19,9 +18,7 @@ import (
|
||||
"github.com/flowy-live/llink/internal/particle"
|
||||
"github.com/flowy-live/llink/internal/speech"
|
||||
"github.com/flowy-live/llink/internal/utils"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"cloud.google.com/go/firestore"
|
||||
@@ -64,22 +61,13 @@ func main() {
|
||||
|
||||
speechSvc := speech.NewSpeechService(ctx)
|
||||
|
||||
pusherAddr := utils.MustGetEnv("PUSHER_GRPC_ADDR")
|
||||
pusherConn, err := grpc.NewClient(pusherAddr, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
slog.Error("failed to connect to pusher", "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer pusherConn.Close()
|
||||
pusherClient := pbpusher.NewPusherServiceClient(pusherConn)
|
||||
|
||||
humanSvc := human.NewService(db.Pool())
|
||||
networkReader := network.NewReader(db.Pool())
|
||||
pushTokenSvc := pushnotify.NewService(db.Pool())
|
||||
// EXPO_ACCESS_TOKEN is required: Enhanced Security is on for our Expo
|
||||
// project (otherwise anyone holding one of our push tokens could spam users).
|
||||
expoClient := pushnotify.NewExpoClient(utils.MustGetEnv("EXPO_ACCESS_TOKEN"))
|
||||
notifier := pushnotify.NewNotifier(networkReader, pushTokenSvc, pusherClient, expoClient)
|
||||
notifier := pushnotify.NewNotifier(networkReader, pushTokenSvc, expoClient)
|
||||
|
||||
client := createClient(ctx)
|
||||
defer client.Close()
|
||||
@@ -327,6 +315,7 @@ func notifyForParticle(
|
||||
transcript string,
|
||||
) {
|
||||
if parent == nil {
|
||||
slog.Info("notify: skip — no parent", "particleID", doc.Ref.ID)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -334,9 +323,13 @@ func notifyForParticle(
|
||||
typeName, _ := typeStr.(string)
|
||||
pType, err := particle.ParseParticleType(typeName)
|
||||
if err != nil {
|
||||
slog.Info("notify: skip — unparseable particle type",
|
||||
"particleID", doc.Ref.ID, "type", typeName, "error", err)
|
||||
return
|
||||
}
|
||||
if pType == particle.TypeStream || pType == particle.TypeFolder {
|
||||
slog.Info("notify: skip — container particle",
|
||||
"particleID", doc.Ref.ID, "type", pType)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -347,6 +340,8 @@ func notifyForParticle(
|
||||
}
|
||||
parentType, err := particle.ParseParticleType(parentStream.Type)
|
||||
if err != nil || parentType != particle.TypeStream {
|
||||
slog.Info("notify: skip — parent isn't a stream",
|
||||
"particleID", doc.Ref.ID, "parentType", parentType, "parseErr", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user