Generate VAPID key pair during startup

This commit is contained in:
Vyr Cossont 2024-11-23 20:32:55 -08:00
commit 821c1da688
4 changed files with 59 additions and 25 deletions

View file

@ -19,7 +19,7 @@ package testrig
import (
"context"
webpushgo "github.com/SherClockHolmes/webpush-go"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/db/bundb"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
@ -368,6 +368,15 @@ func StandardDBSetup(db db.DB, accounts map[string]*gtsmodel.Account) {
log.Panic(ctx, err)
}
vapidKeyPair := &gtsmodel.VAPIDKeyPair{}
var err error
if vapidKeyPair.Private, vapidKeyPair.Public, err = webpushgo.GenerateVAPIDKeys(); err != nil {
log.Panic(nil, err)
}
if err = db.PutVAPIDKeyPair(ctx, vapidKeyPair); err != nil {
log.Panic(nil, err)
}
log.Debug(ctx, "testing db setup complete")
}