~bigbes/core-go

2624a28a52b29713f7ac13b95e0d43f969a1d47c — Robin Jarry 1 year, 8 months ago e559510
webhooks: do not crash when expire is NULL

This is currently not possible to create a webhook without an expiry
date. But the SQL database schema does not forbid it. If in the future
we would like to allow webhooks to be created without an expiry date, we
shouldn't crash when fetching them.

Check for the validity of the Expiry field before checking its value. If
it is nil, assume that the webhooks has no expiry date.

Signed-off-by: Robin Jarry <robin@jarry.cc>
1 files changed, 1 insertions(+), 1 deletions(-)

M webhooks/queue.go
M webhooks/queue.go => webhooks/queue.go +1 -1
@@ 152,7 152,7 @@ func (queue *WebhookQueue) fetchSubscriptions(ctx context.Context,
				&sub.NodeID); err != nil {
				panic(err)
			}
			if sub.Expires.After(time.Now()) {
			if sub.Expires == nil || sub.Expires.After(time.Now()) {
				subs = append(subs, &sub)
			}
		}