This commit is contained in:
2024-12-23 18:00:19 +08:00
parent d31f0fbecd
commit 1b2a4e9ce4
6 changed files with 165 additions and 26 deletions

View File

@@ -59,4 +59,28 @@ export async function GetPrivateKey(pubkey){
export async function GetKeypairFromEmail(email){
const [rows] = await pool.query("SELECT Users.pub_key,Users.email, PrivateKeys.private_key FROM Users JOIN PrivateKeys ON Users.pub_key = PrivateKeys.pub_key WHERE email=?", [email]);
return rows[0];
}
export async function CreateNewRequest(){
const id = uuidv4();
await pool.query(`INSERT INTO Requests (id) VALUES(?)`, [id]);
return id;
}
export async function SetRequestResult(id,result){
const [rows] = await pool.query("UPDATE Requests SET result=?, status=1 WHERE id=?", [result,id]);
return rows.length;
}
function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.replace(/[xy]/g, function (c) {
const r = Math.random() * 16 | 0,
v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}