From 11c38f939d1eb0123bc36780e89155b4c1efd022 Mon Sep 17 00:00:00 2001 From: Johan Stokking Date: Fri, 26 Aug 2022 22:13:46 +0200 Subject: [PATCH] as: Set received_at only on messages that are received --- pkg/applicationserver/applicationserver.go | 2 -- pkg/applicationserver/grpc.go | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/applicationserver/applicationserver.go b/pkg/applicationserver/applicationserver.go index fbcf668cb3c..233053b7532 100644 --- a/pkg/applicationserver/applicationserver.go +++ b/pkg/applicationserver/applicationserver.go @@ -372,8 +372,6 @@ func (as *ApplicationServer) processUp(ctx context.Context, up *ttnpb.Applicatio up.CorrelationIds = events.CorrelationIDsFromContext(ctx) registerReceiveUp(ctx, up) - up.ReceivedAt = ttnpb.ProtoTimePtr(time.Now()) - pass, err := as.handleUp(ctx, up, link) if err != nil { log.FromContext(ctx).WithError(err).Warn("Failed to process upstream message") diff --git a/pkg/applicationserver/grpc.go b/pkg/applicationserver/grpc.go index 3d340fba382..3fb51acf7ed 100644 --- a/pkg/applicationserver/grpc.go +++ b/pkg/applicationserver/grpc.go @@ -17,6 +17,7 @@ package applicationserver import ( "context" "fmt" + "time" pbtypes "github.com/gogo/protobuf/types" clusterauth "go.thethings.network/lorawan-stack/v3/pkg/auth/cluster" @@ -125,6 +126,7 @@ func (as *ApplicationServer) GetConfiguration(ctx context.Context, _ *ttnpb.GetA // HandleUplink implements ttnpb.NsAsServer. func (as *ApplicationServer) HandleUplink(ctx context.Context, req *ttnpb.NsAsHandleUplinkRequest) (*pbtypes.Empty, error) { + now := time.Now() if err := clusterauth.Authorized(ctx); err != nil { return nil, err } @@ -136,6 +138,7 @@ func (as *ApplicationServer) HandleUplink(ctx context.Context, req *ttnpb.NsAsHa return nil, err } for _, up := range req.ApplicationUps { + up.ReceivedAt = ttnpb.ProtoTimePtr(now) if err := as.processUp(ctx, up, link); err != nil { return nil, err }