From 5a2e8341a240dd7676ac76eaa3b5f910b66487a3 Mon Sep 17 00:00:00 2001 From: Vyr Cossont Date: Sat, 23 Nov 2024 20:41:35 -0800 Subject: [PATCH] Return VAPID public key when registering an app --- internal/typeutils/internaltofrontend.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index ccb2db51c..ba6b40f8f 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -615,6 +615,11 @@ func (c *Converter) AccountToAdminAPIAccount(ctx context.Context, a *gtsmodel.Ac } func (c *Converter) AppToAPIAppSensitive(ctx context.Context, a *gtsmodel.Application) (*apimodel.Application, error) { + vapidKeyPair, err := c.state.DB.GetVAPIDKeyPair(ctx) + if err != nil { + return nil, gtserror.Newf("error getting VAPID public key: %w", err) + } + return &apimodel.Application{ ID: a.ID, Name: a.Name, @@ -622,6 +627,7 @@ func (c *Converter) AppToAPIAppSensitive(ctx context.Context, a *gtsmodel.Applic RedirectURI: a.RedirectURI, ClientID: a.ClientID, ClientSecret: a.ClientSecret, + VapidKey: vapidKeyPair.Public, }, nil } @@ -1755,7 +1761,7 @@ func (c *Converter) InstanceToAPIV2Instance(ctx context.Context, i *gtsmodel.Ins vapidKeyPair, err := c.state.DB.GetVAPIDKeyPair(ctx) if err != nil { - return nil, gtserror.Newf("error getting VAPID key pair: %w", err) + return nil, gtserror.Newf("error getting VAPID public key: %w", err) } instance.Configuration.VAPID.PublicKey = vapidKeyPair.Public