Skip to content

Commit

Permalink
chore(mgmt): make ApiToken last_use_time return null for zero value (#…
Browse files Browse the repository at this point in the history
…218)

Because

- Currently, if the `last_use_time` is zero, the API returns a zero
date, which is confusing.

This commit

- Makes `last_use_time` in `ApiToken` return null for zero value.
  • Loading branch information
donch1989 authored Jun 18, 2024
1 parent 12242f8 commit 724fd08
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/service/convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,12 @@ func (s *service) DBToken2PBToken(ctx context.Context, dbToken *datamodel.Token)
Expiration: &mgmtPB.ApiToken_ExpireTime{ExpireTime: timestamppb.New(dbToken.ExpireTime)},
CreateTime: timestamppb.New(dbToken.Base.CreateTime),
UpdateTime: timestamppb.New(dbToken.Base.UpdateTime),
LastUseTime: timestamppb.New(dbToken.LastUseTime),
LastUseTime: func() *timestamppb.Timestamp {
if dbToken.LastUseTime.IsZero() {
return nil
}
return timestamppb.New(dbToken.LastUseTime)
}(),
}, nil
}

Expand Down

0 comments on commit 724fd08

Please sign in to comment.