mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-26 03:03:31 -06:00
Generate VAPID key pair during startup
This commit is contained in:
parent
7a02a19c3c
commit
821c1da688
4 changed files with 59 additions and 25 deletions
|
|
@ -30,6 +30,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/KimMachineGun/automemlimit/memlimit"
|
||||
webpushgo "github.com/SherClockHolmes/webpush-go"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/superseriousbusiness/gotosocial/cmd/gotosocial/action"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/admin"
|
||||
|
|
@ -40,6 +41,7 @@ import (
|
|||
"github.com/superseriousbusiness/gotosocial/internal/filter/spam"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/filter/visibility"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/media/ffmpeg"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/messages"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/metrics"
|
||||
|
|
@ -248,6 +250,22 @@ var Start action.GTSAction = func(ctx context.Context) error {
|
|||
}
|
||||
}
|
||||
|
||||
// Get or create a VAPID key pair.
|
||||
vapidKeyPair, err := dbService.GetVAPIDKeyPair(ctx)
|
||||
if err != nil {
|
||||
return gtserror.Newf("error getting VAPID key pair: %w", err)
|
||||
}
|
||||
if vapidKeyPair == nil {
|
||||
// Generate and store a new key pair.
|
||||
vapidKeyPair = >smodel.VAPIDKeyPair{}
|
||||
if vapidKeyPair.Private, vapidKeyPair.Public, err = webpushgo.GenerateVAPIDKeys(); err != nil {
|
||||
return gtserror.Newf("error generating VAPID key pair: %w", err)
|
||||
}
|
||||
if err := dbService.PutVAPIDKeyPair(ctx, vapidKeyPair); err != nil {
|
||||
return gtserror.Newf("error putting VAPID key pair: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize both home / list timelines.
|
||||
state.Timelines.Home = timeline.NewManager(
|
||||
tlprocessor.HomeTimelineGrab(state),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue