Skip to content

Commit

Permalink
as: Set received_at only on messages that are received
Browse files Browse the repository at this point in the history
  • Loading branch information
johanstokking committed Aug 26, 2022
1 parent 5078e70 commit 11c38f9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 0 additions & 2 deletions pkg/applicationserver/applicationserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions pkg/applicationserver/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit 11c38f9

Please sign in to comment.