@@ -474,6 +474,20 @@ public static class DbSeeder
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
// Generate the VAPID key pair once so Web Push works out of the box. Persisted on the
|
||||
// singleton row; the public key is handed to browsers, the private key signs each push.
|
||||
var row = await db.NotificationSettings.OrderBy(s => s.Id).FirstAsync();
|
||||
if (string.IsNullOrWhiteSpace(row.VapidPublicKey))
|
||||
{
|
||||
var keys = WebPush.VapidHelper.GenerateVapidKeys();
|
||||
row.VapidPublicKey = keys.PublicKey;
|
||||
row.VapidPrivateKey = keys.PrivateKey;
|
||||
if (string.IsNullOrWhiteSpace(row.VapidSubject))
|
||||
row.VapidSubject = "mailto:admin@rolac.local";
|
||||
row.EnableWebPush = true;
|
||||
await db.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user