mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-22 04:03:49 +01:00
[backend] Generate VAPID keys during meta bootstrap
This commit is contained in:
parent
4006e74eca
commit
eadf9acdc3
@ -1,5 +1,6 @@
|
||||
import { db } from "@/db/postgre.js";
|
||||
import { Meta } from "@/models/entities/meta.js";
|
||||
import push from 'web-push';
|
||||
|
||||
let cache: Meta;
|
||||
|
||||
@ -46,12 +47,16 @@ export async function fetchMeta(noCache = false): Promise<Meta> {
|
||||
cache = meta;
|
||||
return meta;
|
||||
} else {
|
||||
const { publicKey, privateKey } = push.generateVAPIDKeys();
|
||||
|
||||
// If fetchMeta is called at the same time when meta is empty, this part may be called at the same time, so use fail-safe upsert.
|
||||
const saved = await transactionalEntityManager
|
||||
.upsert(
|
||||
Meta,
|
||||
{
|
||||
id: "x",
|
||||
swPublicKey: publicKey,
|
||||
swPrivateKey: privateKey,
|
||||
},
|
||||
["id"],
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user