From de0992d41e6075c294559cf6420df2414d3ce48c Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 15 Jun 2022 09:09:28 +0200 Subject: [PATCH] downstream: fix panic in findWebPushSubscription for unbound conns This code has been missed when adding webpush support for downstream connections without an upstream network bound. --- downstream.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/downstream.go b/downstream.go index 371ac40..57f9732 100644 --- a/downstream.go +++ b/downstream.go @@ -3377,7 +3377,12 @@ func (dc *downstreamConn) handleNickServPRIVMSG(ctx context.Context, uc *upstrea } func (dc *downstreamConn) findWebPushSubscription(ctx context.Context, endpoint string) (*database.WebPushSubscription, error) { - subs, err := dc.user.srv.db.ListWebPushSubscriptions(ctx, dc.network.ID) + var networkID int64 + if dc.network != nil { + networkID = dc.network.ID + } + + subs, err := dc.user.srv.db.ListWebPushSubscriptions(ctx, networkID) if err != nil { return nil, err }